Submission #1164103


Source Code Expand

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

typedef long long ll;

int a[101];

int main(){
	int k, t;
	
	cin >> k >> t;
	
	REP(i,t) scanf("%d", &a[i]);
	
	int f = 0;
	
	REP(i,t){
		if (a[i] < k/t){
			f = 1;
			break;
		}
	}
	
	if (t == 1) cout << k-1 << endl;
	else{
		if (f == 0) cout << 0 << endl;
		else{
			int ans = -1;
			
			sort(a,a+t);
			
			int sum = 0;
			
			REP(i,t-1) sum += a[i];
			
			int i = 1;
			
			while (ans > i || ans == -1){
				ans = a[t-1] - i - sum*i; 
				
				i++;
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  REP(i,t) scanf("%d", &a[i]);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 8
WA × 2
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 AC 1 ms 256 KB
1_005.txt AC 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 WA 1 ms 256 KB