제출 #531098

#제출 시각아이디문제언어결과실행 시간메모리
531098xuliuSails (IOI07_sails)C++17
5 / 100
1085 ms7696 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define debug if(0) const int mod = 1e9 + 7; const ll infL = 1e18 + 7; const int inf = 1e9 + 7; void add(int &a, int b) { a = (a+b)%mod; } int add(int a, int b, int c) { int res = (((a+b)%mod) + c)%mod; return res; } const int M = 1e5 + 4; ll cnt[M]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<int> h(n), k(n); for(int i=0; i<n; i++) { cin>>h[i]>>k[i]; } for(int i=0; i<n; i++) { set<pair<int, int>> S; for(int j=1; j<=h[i]; j++) { S.insert({cnt[j], j}); } for(int j=0; j<k[i]; j++) { pair<int, int> p = *S.begin(); S.erase(S.begin()); cnt[p.second]++; } } ll ans = 0; for(int i=1; i<M; i++) { ans += ((cnt[i]*(cnt[i]-1))/2); } cout<<ans; }
#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...