Submission #422937

# Submission time Handle Problem Language Result Execution time Memory
422937 2021-06-10T14:23:55 Z EndRay Sails (IOI07_sails) C++17
10 / 100
1000 ms 2848 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 < n; ++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)
      |               ~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 3 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 996 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 1448 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 2848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 2388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 2512 KB Time limit exceeded
2 Halted 0 ms 0 KB -