# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
145271 |
2019-08-19T12:43:34 Z |
Sorting |
Sails (IOI07_sails) |
C++14 |
|
34 ms |
3064 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int n;
pair<long long, long long> a[MAXN]; //height, number of sails
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 0; i < n; ++i){
cin >> a[i].first >> a[i].second;
}
sort(a, a + n);
long long ans = 0, cnt = 0;
long long mn = MAXN;
for(int i = n - 1; i >= 0; --i){
mn = min(a[i].first, mn);
if(mn > a[i].second){
ans += a[i].second * cnt;
mn -= a[i].second;
}
else{
ans += mn * cnt;
++cnt;
ans += (a[i].second - mn) * cnt;
mn = a[i].first - (a[i].second - mn);
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1144 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1656 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
2300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
2808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |