Submission #114179

# Submission time Handle Problem Language Result Execution time Memory
114179 2019-05-31T08:13:40 Z zubec Sails (IOI07_sails) C++14
40 / 100
1000 ms 6640 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

vector <pair<int, int> > vec;

int n;

multiset<int> q;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++){
        int h, k;
        cin >> h >> k;
        vec.push_back({h, k});
    }
    sort(vec.begin(), vec.end());
    int mxh = 0;
    for (int i = 0; i < vec.size(); i++){
        while(mxh < vec[i].first){
            ++mxh;
            q.insert(0);
        }
        vector <int> vec2;
        while(vec[i].second > 0){
            int kol = *q.begin();
            q.erase(q.begin());
            vec2.push_back(kol+1);
            --vec[i].second;
        }
        for (int j = 0; j < vec2.size(); j++)
            q.insert(vec2[j]);
    }
    ll ans = 0;
    while(!q.empty()){
        ans += *q.begin()*1ll*(*q.begin()-1)/2;
        q.erase(q.begin());
    }
    cout << ans;

}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:23:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
sails.cpp:35:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < vec2.size(); j++)
                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 18 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 389 ms 512 KB Output is correct
2 Correct 370 ms 5220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 1552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 1368 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 1896 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 6640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 3060 KB Time limit exceeded
2 Halted 0 ms 0 KB -