Submission #1466987
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second
const ll inf = 10000000001000000;
int n;
ll a[55];
int main() {
ll sum=0;
scanf("%d", &n);
FOR(i,n) scanf("%lld", &a[i]);
FOR(i,n) sum += a[i];
for (ll k = sum - n*(n-1); k <= sum; k++) {
if (k < 0) continue;
bool ok=true;
ll res=0;
FOR(i,n) {
ll mlo = (a[i]+k+1) / (n+1), mhi = (a[i]+k) / (n+1);
if (mlo <= mhi) res += mlo;
else ok=false;
}
if (ok && res==k) {
printf("%lld\n", res);
return 0;
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Decrease (Judge ver.) |
User |
ania |
Language |
C++14 (GCC 5.4.1) |
Score |
600 |
Code Size |
1008 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:24:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:25:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
FOR(i,n) scanf("%lld", &a[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
600 / 600 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0, example1, example2, example3, example4 |
All |
example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, small0, small1, small2, small3, small4, small5, small6, small7, small8, small9 |
Case Name |
Status |
Exec Time |
Memory |
example0 |
AC |
1 ms |
256 KB |
example1 |
AC |
1 ms |
256 KB |
example2 |
AC |
1 ms |
256 KB |
example3 |
AC |
1 ms |
256 KB |
example4 |
AC |
1 ms |
256 KB |
maxrand0 |
AC |
1 ms |
256 KB |
maxrand1 |
AC |
2 ms |
256 KB |
maxrand2 |
AC |
1 ms |
256 KB |
maxrand3 |
AC |
2 ms |
256 KB |
maxrand4 |
AC |
1 ms |
256 KB |
maxrand5 |
AC |
2 ms |
256 KB |
maxrand6 |
AC |
1 ms |
256 KB |
maxrand7 |
AC |
2 ms |
256 KB |
maxrand8 |
AC |
1 ms |
256 KB |
maxrand9 |
AC |
2 ms |
256 KB |
rand0 |
AC |
1 ms |
256 KB |
rand1 |
AC |
1 ms |
256 KB |
rand2 |
AC |
1 ms |
256 KB |
rand3 |
AC |
1 ms |
256 KB |
rand4 |
AC |
1 ms |
256 KB |
rand5 |
AC |
1 ms |
256 KB |
rand6 |
AC |
1 ms |
256 KB |
rand7 |
AC |
2 ms |
256 KB |
rand8 |
AC |
1 ms |
256 KB |
rand9 |
AC |
1 ms |
256 KB |
small0 |
AC |
1 ms |
256 KB |
small1 |
AC |
1 ms |
256 KB |
small2 |
AC |
1 ms |
256 KB |
small3 |
AC |
1 ms |
256 KB |
small4 |
AC |
2 ms |
256 KB |
small5 |
AC |
2 ms |
256 KB |
small6 |
AC |
1 ms |
256 KB |
small7 |
AC |
1 ms |
256 KB |
small8 |
AC |
2 ms |
256 KB |
small9 |
AC |
2 ms |
256 KB |