# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139535 | 2019-08-01T00:45:55 Z | Boxworld | Sails (IOI07_sails) | C++14 | 1000 ms | 1420 KB |
#include <bits/stdc++.h> using namespace std; const int N=100010; pair<int,int> a[N]; int s[N],L[N]; int main(){ int n,tmp=0,MX=0; scanf("%d",&n); for (int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second); sort(a,a+n); for (int i=0;i<n;i++){ s[0]+=a[i].first-tmp; int cnt=a[i].second; for (int j=0;j<=MX;j++) if (cnt>s[j]){ L[j+1]=s[j]; cnt-=s[j]; s[j]=0; }else{ L[j+1]=cnt; s[j]-=cnt; cnt=0; break; } if (L[MX+1]>0)MX++; for (int j=0;j<=MX;j++)s[j]+=L[j],L[j]=0; tmp=a[i].first; } long long ans=0; for (int i=0;i<=n;i++)ans+=(long long)s[i]*i*(i-1)/2; 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 | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 464 KB | Output is correct |
2 | Correct | 740 ms | 1148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1060 ms | 892 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 844 ms | 916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1077 ms | 1168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 1420 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1049 ms | 1332 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |