Submission #114203

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

vector <pair<int, int> > vec;

int n;

int kol[100100];

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++){
        if (mxh < vec[i].first){
            kol[0] += vec[i].first-mxh;
            mxh = vec[i].first;
        }
        vector <pair<int, int> > vec2;
        for (int j = 0; j <= mxh && vec[i].second > 0; j++){
            int mn = min(kol[j], vec[i].second);
            if (mn > 0){
                vec[i].second -= mn;
                vec2.push_back({j, mn});
                kol[j] -= mn;
            }
        }
        for (int j = 0; j < vec2.size(); j++){
            kol[vec2[j].first+1] += vec2[j].second;
        }
    }
    ll ans = 0;
    for (int j = 0; j <= mxh; j++){
        ans += kol[j]*1ll*j*(j-1)/2;
    }
    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:37: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 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 284 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 504 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 640 KB Output is correct
2 Incorrect 207 ms 1084 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 1000 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 1076 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1576 KB Time limit exceeded
2 Halted 0 ms 0 KB -