Submission #890396

# Submission time Handle Problem Language Result Execution time Memory
890396 2023-12-21T05:57:02 Z Sir_Ahmed_Imran Sails (IOI07_sails) C++17
40 / 100
1000 ms 4888 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define all(x) (x).begin(),(x).end()
void solve(){
    ll n,m,o,p,q,r;
    cin>>n;
    vector<pair<ll,ll>> v;
    for(int i=0;i<n;i++){
        cin>>p>>q;
        v.append({p,q});
    }
    sort(all(v));
    vector<ll> x;
    priority_queue<ll,vector<ll>,greater<ll>> Q;
    o=p=0;
    for(auto& i:v){
        for(int j=p;j<i.ff;j++)
            Q.push(0);
        for(int j=0;j<i.ss;j++){
            o+=Q.top();
            x.append(Q.top()+1);
            Q.pop();
        }
        while(!x.empty()){
            Q.push(x.back());
            x.pop_back();
        }
        p=i.ff;
    }
    cout<<o;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    solve();
    return 0;
}

Compilation message

sails.cpp: In function 'void solve()':
sails.cpp:11:10: warning: unused variable 'm' [-Wunused-variable]
   11 |     ll n,m,o,p,q,r;
      |          ^
sails.cpp:11:18: warning: unused variable 'r' [-Wunused-variable]
   11 |     ll n,m,o,p,q,r;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 612 KB Output is correct
2 Correct 137 ms 1532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 1092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 1424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 2008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 4888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 3548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 3528 KB Time limit exceeded
2 Halted 0 ms 0 KB -