# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
113405 | 2019-05-25T12:04:20 Z | TadijaSebez | Sails (IOI07_sails) | C++11 | 1000 ms | 1024 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=mxh-1;i>=1;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 | 256 KB | Output is correct |
2 | Correct | 17 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 18 ms | 368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1006 ms | 384 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1064 ms | 512 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1040 ms | 640 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1070 ms | 640 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1083 ms | 1024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1066 ms | 1024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |