Submission #518558

# Submission time Handle Problem Language Result Execution time Memory
518558 2022-01-24T06:24:02 Z blue Sails (IOI07_sails) C++17
30 / 100
1000 ms 2420 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

#define sz(x) int(x.size())

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

    int N;
    cin >> N;

    pii S[N];
    for(int i = 0; i < N; i++) cin >> S[i].first >> S[i].second;

    sort(S, S+N);

    vi locs;

    for(pii& s: S)
    {
        // cerr << s.first << ' ' << s.second << '\n';
        while(sz(locs) < s.first) locs.push_back(0);

        // while(s.second--)
        // {
        //     locs[0]++;
        // }
        sort(locs.begin(), locs.end());
        for(int i = 0; i < s.second; i++) locs[i]++;
    }

    ll ans = 0;
    for(ll l: locs)
    {
        // cerr << l << '\n';
        ans += ((l)*(l-1))/2;
    }

    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 356 KB Output is correct
2 Execution timed out 1079 ms 960 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 1288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 2420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1002 ms 2224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1024 ms 2332 KB Time limit exceeded
2 Halted 0 ms 0 KB -