Submission #773296

# Submission time Handle Problem Language Result Execution time Memory
773296 2023-07-04T20:02:27 Z rominanafu Sails (IOI07_sails) C++11
40 / 100
1000 ms 1968 KB
#include <bits/stdc++.h>
#define pii pair<int,int>

using namespace std;
typedef long long ll;

struct ura {
    int h, k;
};

int n;
int max_alt;
ura masts[100005];
int alturas[100005];
ll resp;
priority_queue<int> q;

bool cmp(ura &a, ura &b) {
    return a.h < b.h;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> masts[i].h >> masts[i].k;
    }
    sort(masts, masts+n, cmp);
    vector<int> add;
    int a;
    for(int i=0; i<n; i++) {
        while (!add.empty()) {
            q.push(add.back());
            add.pop_back();
        }
        while (max_alt < masts[i].h) {
            q.push(0);
            max_alt++;
        }
        while (masts[i].k--) {
            a = q.top();
            q.pop();
            add.push_back(a-1);
            resp += a * -1;
        }
    }
    cout << resp;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 392 KB Output is correct
2 Correct 142 ms 940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 1968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 1160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1252 KB Time limit exceeded
2 Halted 0 ms 0 KB -