Submission #84339

#TimeUsernameProblemLanguageResultExecution timeMemory
84339win11905Sails (IOI07_sails)C++11
15 / 100
1083 ms7940 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]; int num[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d %d", h+i, k+i); for(int i = n; i > 0; --i) { vector<pii> now; for(int j = 1; j <= h[i]; ++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[i]; ++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:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sails.cpp:16:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; ++i) scanf("%d %d", h+i, k+i);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~
#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...