Submission #776158

# Submission time Handle Problem Language Result Execution time Memory
776158 2023-07-07T10:55:29 Z Ahmed57 Sails (IOI07_sails) C++17
5 / 100
47 ms 4440 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 = 100000 , ans = -1;
    while(l<=r){
        long long mid = (l+r)/2;
        multiset<int> s;
        long long global = 0 , all = 0;
        priority_queue<int> ve;
        for(int i = 5;i>=1;i--){
            for(auto j:v[i]){
                ve.push(j);
            }
            while(ve.size()&&s.size()<mid){
                s.insert(ve.top()+global);
                ve.pop();
            }
            global++;
            long long sz = s.size();
            all+=(sz*(sz-1))/2;
            while(s.size()&&(*s.begin())<=global){
                s.erase(s.begin());
            }
        }
        if(ve.empty()&&s.empty()){
            ans = all;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    cout<<ans<<endl;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:23:38: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   23 |             while(ve.size()&&s.size()<mid){
      |                              ~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Incorrect 1 ms 2644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2516 KB Output is correct
2 Incorrect 1 ms 2644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 3552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 4404 KB Output isn't correct
2 Halted 0 ms 0 KB -