| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361124 | tarjanmici | Sails (IOI07_sails) | C++20 | 1096 ms | 1504 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
int n, high=0;
cin >> n;
vector<pair<int, int>> mast(n);
vector<int> cnt(100001);
cnt[0] = 100002;
for (int i = 0; i < n; i++) {
cin >> mast[i].first >> mast[i].second;
high = max(high, mast[i].first);
}
sort(mast.begin(), mast.end());
for (int i = 0; i < n; i++) {
int h = mast[i].first, k = mast[i].second;
for (int j = h; j > h - k; j--) {
cnt[j]++;
}
if (cnt[h - k] < cnt[h - k + 1]) {
int j = h - k, l = h - k + 1;
while (cnt[l] == cnt[h - k + 1])l++;
while (cnt[j] == cnt[h - k]) j--;
for (int m = j+1; m - j <= l - (h - k + 1); m++) cnt[m]++;
for (int m = h - k + 1; m < l; m++)cnt[m]--;
}
}
ll ans = 0;
for (int i = 1; i <= high; i++) {
ans += ll(cnt[i]) * ll(cnt[i] - 1) / 2;
}
cout << ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
