Submission #412424

# Submission time Handle Problem Language Result Execution time Memory
412424 2021-05-26T21:01:51 Z Dakto Sails (IOI07_sails) C++17
0 / 100
127 ms 6832 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0; i<n; i++) cin>>v[i].first>>v[i].second;
    long long res=1e16;
    unordered_map<int,long long> m;
    long long s=0;
    for(auto i:v) m[i.first]+=i.second;
    for(auto i:v) s+=i.second;

    auto check=[&](long long c){
        long long v=0;
        long long tr=0;
        long long ts=0;
        for(int i=100000; i>=1; i--){
            v+=m[i];
            int d=min(v,c-(s-ts<=i?1:0));
            tr+=d*(d-1)/2;
            v-=d;
            ts+=m[i];
        }
        if(!v) res=min(res,tr);
        return v==0;
    };
    int l=1, r=1e5;
    while(l<r){
        int m=(l+r)/2;
        if(check(m)) r=m;
        else l=m+1;
    }
    cout<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 5032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 5056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 5468 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 5796 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 6376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 6660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 6832 KB Output isn't correct
2 Halted 0 ms 0 KB -