Submission #701269

# Submission time Handle Problem Language Result Execution time Memory
701269 2023-02-20T17:08:33 Z Hanksburger Sails (IOI07_sails) C++17
30 / 100
51 ms 5512 KB
#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100005];
multiset<int> s;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, cnt, ans=0;
    cin >> n;
    for (int i=1; i<=n; i++)
        cin >> a[i].first >> a[i].second;
    sort(a+1, a+n+1);
    for (int i=1; i<=n; i++)
    {
        auto it=s.lower_bound(a[i].first-a[i].second+1);
        int 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 324 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 3416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 5512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 3416 KB Output isn't correct
2 Halted 0 ms 0 KB -