Submission #903887

# Submission time Handle Problem Language Result Execution time Memory
903887 2024-01-11T13:26:23 Z JakobZorz Sails (IOI07_sails) C++17
40 / 100
1000 ms 6904 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second

void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>>arr(n);
    for(auto&i:arr)
        cin>>i.first>>i.second;
    sort(arr.begin(),arr.end());
    int ph=0;
    multiset<int>s;
    ll r=0;
    for(auto [h,k]:arr){
        for(int i=ph;i<h;i++)
            s.insert(0);
        vector<int>v;
        for(int i=0;i<k;i++){
            v.push_back(*s.begin());
            r+=v.back();
            s.erase(s.begin());
        }
        for(int i:v)
            s.insert(i+1);
        ph=h;
    }
    cout<<r<<"\n";
}

int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}

/*
 
6
3 2
5 3
4 1
2 1
4 3
3 2
 
 */
# 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 448 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 2 ms 348 KB Output is correct
2 Correct 13 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 375 ms 680 KB Output is correct
2 Correct 328 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 1444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 1204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 1912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 6904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 2388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 3260 KB Time limit exceeded
2 Halted 0 ms 0 KB -