Submission #2239483
Source Code Expand
#include<bits/stdc++.h> using namespace std; using LL = long long; LL N, M, S, A[50]; inline LL ceil(LL d, LL n) {return (d+n-1)/n;} inline bool ok(LL x) { if(M < S-x) return false; LL s = 0; for(auto i=0; i<N; ++i) s += ceil(A[i]+x+1-N, N+1); return s <= x; } int main() { scanf("%lld", &N); M=N*(N-1); for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i]; if(ok(0)) {puts("0"); return 0;} LL l = -1, h = 1e18; while(l+1 < h) { LL m = (l+h)>>1; if(ok(m)) h = m; else l = m; } for(auto x=h; -N<x; x-=N) if(!ok(max(0ll,x))) { ++x; while(!ok(x)) ++x; printf("%lld\n", x); return 0; } }
Submission Info
Submission Time | |
---|---|
Task | E - Decrease (Judge ver.) |
User | chabo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 669 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &N); ^ ./Main.cpp:15:54: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i]; ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 1 ms | 256 KB |
maxrand2 | AC | 1 ms | 256 KB |
maxrand3 | AC | 1 ms | 256 KB |
maxrand4 | AC | 1 ms | 256 KB |
maxrand5 | WA | 1 ms | 256 KB |
maxrand6 | AC | 1 ms | 256 KB |
maxrand7 | AC | 1 ms | 256 KB |
maxrand8 | AC | 1 ms | 256 KB |
maxrand9 | WA | 1 ms | 256 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | WA | 1 ms | 256 KB |
rand3 | WA | 1 ms | 256 KB |
rand4 | AC | 1 ms | 256 KB |
rand5 | AC | 1 ms | 256 KB |
rand6 | AC | 1 ms | 256 KB |
rand7 | WA | 1 ms | 256 KB |
rand8 | AC | 1 ms | 256 KB |
rand9 | WA | 1 ms | 256 KB |
small0 | AC | 1 ms | 256 KB |
small1 | WA | 1 ms | 256 KB |
small2 | AC | 1 ms | 256 KB |
small3 | WA | 1 ms | 256 KB |
small4 | AC | 1 ms | 256 KB |
small5 | WA | 1 ms | 256 KB |
small6 | AC | 1 ms | 256 KB |
small7 | WA | 1 ms | 256 KB |
small8 | AC | 1 ms | 256 KB |
small9 | AC | 1 ms | 256 KB |