Submission #934341

#TimeUsernameProblemLanguageResultExecution timeMemory
934341thinknoexitSails (IOI07_sails)C++17
5 / 100
20 ms3144 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...