Submission #519636

# Submission time Handle Problem Language Result Execution time Memory
519636 2022-01-26T20:50:48 Z sofapuden Sails (IOI07_sails) C++14
40 / 100
1000 ms 2456 KB
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<pair<int,int>> v(n);
    for(auto &x : v)cin >> x.first >> x.second;
    set<pair<int,int>> S;
    S.insert({1,-1});
    sort(v.begin(),v.end());
    int cn = -2;
    for(int i = 0; i < n; ++i){
        int z = v[i].second;
        int mx = v[i].first;
        auto it = prev(S.end());
        vector<pair<int,int>> del, add;
        bool ok = 0;
        while(z){
            if((*it).first == 1)ok = 1;
            del.push_back(*it);
            int am = min(z,mx-(*it).first+1);
            z-=am;
            add.push_back({(*it).first+am,(*it).second});
            mx = (*it).first-1;
            it = prev(it);
        }
        for(auto x : del)S.erase(x);
        for(auto x : add)S.insert(x);
        if(ok){
            S.insert({1,cn--});
        }
    }
    long long ans = 0;
    for(auto x : S){
        ans += -1ll * (x.first-1) * (x.second+1);
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 14 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 364 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 1204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 1476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 2456 KB Time limit exceeded
2 Halted 0 ms 0 KB -