# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701270 |
2023-02-20T17:08:59 Z |
Hanksburger |
Sails (IOI07_sails) |
C++17 |
|
46 ms |
5108 KB |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[100005];
multiset<long long> s;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, cnt, ans=0;
cin >> n;
for (long long i=1; i<=n; i++)
cin >> a[i].first >> a[i].second;
sort(a+1, a+n+1);
for (long long i=1; i<=n; i++)
{
auto it=s.lower_bound(a[i].first-a[i].second+1);
long long l=0, r=a[i].first;
if (it!=s.begin())
{
l=*prev(it);
s.erase(prev(it));
}
if (it!=s.end())
{
r=*it;
s.erase(it);
s.insert(a[i].first);
}
s.insert(l+a[i].second-(a[i].first-r));
}
cnt=s.size();
for (auto it=s.begin(); it!=s.end(); it++)
{
if (it==s.begin())
ans+=cnt*(cnt-1)/2*(*it);
else
ans+=cnt*(cnt-1)/2*(*it-*prev(it));
cnt--;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Output is correct |
2 |
Correct |
13 ms |
2104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
3148 KB |
Output is correct |
2 |
Correct |
30 ms |
3148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
5108 KB |
Output is correct |
2 |
Correct |
22 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
3068 KB |
Output is correct |
2 |
Correct |
35 ms |
3152 KB |
Output is correct |