Submission #934341

# Submission time Handle Problem Language Result Execution time Memory
934341 2024-02-27T07:46:49 Z thinknoexit Sails (IOI07_sails) C++17
5 / 100
20 ms 3144 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
pair<int, int> a[100100];
ll qs[100100];
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1;i <= n;i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + 1 + n, greater<pair<int, int>>());
    int now = 100000;
    for (int i = 1;i <= n;i++) {
        now = min(now, a[i].first);
        int k = a[i].second;
        if (k > now) {
            qs[1]++;
            qs[now + 1]--;
            k -= now;
            now = a[i].first;
        }
        qs[now + 1]--;
        qs[now - k + 1]++;
        now -= k;
    }
    ll ans = 0;
    for (int i = 1;i <= 100000;i++) {
        qs[i] += qs[i - 1];
        ans += qs[i] * (qs[i] - 1) / 2;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 2180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3144 KB Output isn't correct
2 Halted 0 ms 0 KB -