Submission #776156

# Submission time Handle Problem Language Result Execution time Memory
776156 2023-07-07T10:54:17 Z Ahmed57 Sails (IOI07_sails) C++17
5 / 100
45 ms 5580 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);
    }
    int l = 1 , r = 100000 , ans = -1;
    while(l<=r){
        int mid = (l+r)/2;
        multiset<int> s;
        int 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 '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 1 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Incorrect 2 ms 2644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 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 2640 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 5 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 3880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 4100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 4084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 5516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -