# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84355 | win11905 | Sails (IOI07_sails) | C++11 | 1077 ms | 3696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 1e5+5;
int n, h[N], k[N];
vector<pii> V;
int num[N];
int main() {
scanf("%d", &n);
for(int i = 0, a, b; i < n; ++i) scanf("%d %d", &a, &b), V.emplace_back(a, b);
sort(V.begin(), V.end());
for(auto x : V) {
int h, k; tie(h, k) = x;
vector<pii> now;
for(int j = 1; j <= h; ++j) now.emplace_back(num[j], j);
sort(now.begin(), now.end(), [&](const pii &a, const pii &b) {
if(a.x == b.x) return a.y > b.y;
return a.x < b.x;
});
for(int j = 0; j < k; ++j) num[now[j].y]++;
}
long ans = 0;
for(int i = 1; i < N; ++i) if(num[i]) ans += 1ll * num[i] * (num[i] - 1) / 2;
printf("%lld\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |