# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78700 | 2018-10-07T20:19:33 Z | Vardanyan | Sails (IOI07_sails) | C++14 | 1000 ms | 7700 KB |
#include <bits/stdc++.h> using namespace std; const int N = 100*1000+7; pair<int,int> a[N]; int d[N]; int main(){ int n; scanf("%d",&n); int H = 0; for(int i = 1;i<=n;i++){ scanf("%d%d",&a[i].first,&a[i].second); H = max(H,a[i].first); } sort(a+1,a+1+n); set<pair<int,int> > ms; for(int i = 1;i<=H;i++){ ms.insert({0,i}); } for(int i = 1;i<=n;i++){ set<pair<int,int> >::iterator it = ms.begin(); int c = 0; vector<pair<int,int> > v; for(;it!=ms.end();it++){ pair<int,int> x = *it; if(x.second<=a[i].first) c++; else continue; //ms.erase(ms.find(x)); v.push_back(x); if(c >= a[i].second) break; } for(int j = 0;j<v.size();j++){ ms.erase(ms.find(v[j])); v[j].first++; ms.insert(v[j]); } } long long ans = 0; for(set<pair<int,int> >::iterator it = ms.begin();it!=ms.end();it++){ pair<int,int> x = *it; long long u = x.first; u*=(u-1); u/=2; ans+=u; } cout<<ans<<endl; 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 | 448 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 544 KB | Output is correct |
2 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 620 KB | Output is correct |
2 | Correct | 26 ms | 624 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 731 ms | 996 KB | Output is correct |
2 | Execution timed out | 1071 ms | 5532 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1068 ms | 5532 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1060 ms | 5532 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1066 ms | 5532 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 7700 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1074 ms | 7700 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 7700 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |