Submission #84355

#TimeUsernameProblemLanguageResultExecution timeMemory
84355win11905Sails (IOI07_sails)C++11
30 / 100
1077 ms3696 KiB
#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)

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 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...