이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |