Submission #84355

# Submission time Handle Problem Language Result Execution time Memory
84355 2018-11-14T12:52:56 Z win11905 Sails (IOI07_sails) C++11
30 / 100
1000 ms 3696 KB
#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

sails.cpp: In function 'int main()':
sails.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sails.cpp:17:60: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0, a, b; i < n; ++i) scanf("%d %d", &a, &b), V.emplace_back(a, b);
                                      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB Output is correct
2 Correct 3 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 680 KB Output is correct
2 Correct 12 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 336 ms 776 KB Output is correct
2 Execution timed out 1074 ms 2192 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 2192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2192 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 2192 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 3696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 3696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 3696 KB Time limit exceeded
2 Halted 0 ms 0 KB -