# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
113404 | 2019-05-25T12:02:47 Z | TadijaSebez | Sails (IOI07_sails) | C++11 | 1000 ms | 2200 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=100050; int sum[N],cnt[N]; ll suf[N]; int main() { int n,h,k,mxh=0; scanf("%i",&n); for(int i=1;i<=n;i++) { scanf("%i %i",&h,&k); cnt[h]++; sum[h-k+1]++; sum[h+1]--; mxh=max(mxh,h); } for(int i=1;i<=mxh;i++) sum[i]+=sum[i-1]; while(1) { bool ok=0; for(int i=1;i<mxh;i++) if(sum[i]<sum[i+1]) sum[i]++,sum[i+1]--,ok=1; if(!ok) break; } ll ans=0; for(int i=1;i<=mxh;i++) ans+=(ll)sum[i]*(sum[i]-1)/2; /*for(int i=mxh;i>=1;i--) suf[i]=suf[i+1]+(ll)sum[i]*(sum[i]-1)/2; ll tmp=0,ans=suf[1]; for(int i=1;i<=mxh;i++) { tmp+=sum[i]; ll all=tmp/i,ost=tmp%i; ll now=suf[i+1]+(i-ost)*all*(all-1)/2+ost*all*(all+1)/2; ans=min(ans,now); }*/ printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 18 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1066 ms | 384 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1071 ms | 640 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1072 ms | 896 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1050 ms | 1280 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1048 ms | 1664 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1043 ms | 2200 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 2168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |