Submission #776163

# Submission time Handle Problem Language Result Execution time Memory
776163 2023-07-07T11:00:49 Z Ahmed57 Sails (IOI07_sails) C++17
25 / 100
1000 ms 4712 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v[100001];
    for(int i = 0;i<n;i++){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
    }
    long long l = 1 , r = 10000000 , ans = -1;
    while(l<=r){
        int mid = (l+r)/2;
        long long all = 0;
        priority_queue<long long> ve;
        for(int i = 100000;i>=1;i--){
            for(auto j:v[i]){
                ve.push(j);
            }
            long long sz = min(int(ve.size()),mid);
            all+=(sz*(sz-1))/2;
            vector<int> xd;
            while(sz--){
                xd.push_back(ve.top()-1);
                ve.pop();
            }
            for(auto j:xd){if(j)ve.push(j);}
        }
        if(ve.empty()){
            ans = all;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2644 KB Output is correct
2 Correct 7 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2516 KB Output is correct
2 Correct 7 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2644 KB Output is correct
2 Correct 7 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 2688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 2828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 3676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 3716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 3528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 4712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 4684 KB Time limit exceeded
2 Halted 0 ms 0 KB -