Submission #1164044


Source Code Expand

#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int>P;


int main() {
	int K, T;
	cin >> K >> T;

	int a[110];
	for (int i = 0; i < T; i++)
		cin >> a[i];

	sort(a, a + T);
	reverse(a,a + T);

	int j = 1;
	int type = -1;
	int ans = 0;
	int flag = 0;
	if (T == 1) {
		cout << K - 1 << endl;
	}
	else {
		for (int i = 0; i < K; i++) {
			if ((i % 2 == 0 && a[0] != 0) || flag) {
				a[0]--;
			}
			else {
				while (a[j] == 0 && !flag) {
					j++;
					if (j == T) ans = a[0];
				}
				a[j]--;
				j++;
				if (j > T-1)j = 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task B - K Cakes
User jj
Language C++14 (GCC 5.4.1)
Score 0
Code Size 847 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 7
WA × 3
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt WA 1 ms 256 KB
1_005.txt WA 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt WA 1 ms 256 KB
1_009.txt AC 1 ms 256 KB