Submission #422947

# Submission time Handle Problem Language Result Execution time Memory
422947 2021-06-10T14:39:12 Z EndRay Sails (IOI07_sails) C++17
40 / 100
1000 ms 2072 KB
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 1e5+1;

int n;
pair<int, int> p[N];

int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;
    sort(p, p+n);
    vector<ll> v;
    for(int i = 0; i < n; ++i){
        while(v.size() < p[i].first)
            v.push_back(0);
        for(int j = 0; j < p[i].second; ++j)
            ++v[v.size()-1-j];
        sort(v.begin(), v.end(), greater<ll>());
    }
    ll ans = 0;
    for(int i = 0; i < v.size(); ++i)
        ans += (v[i]-1)*v[i]/2;
    cout << ans << "\n";
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:21:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         while(v.size() < p[i].first)
      |               ~~~~~~~~~^~~~~~~~~~~~
sails.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i < v.size(); ++i)
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 332 KB Output is correct
2 Correct 902 ms 1416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 740 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 924 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 2072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 1120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1304 KB Time limit exceeded
2 Halted 0 ms 0 KB -