# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138523 | Boxworld | Sails (IOI07_sails) | C++14 | 1068 ms | 3280 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxN=100100;
pii a[maxN];
int s[maxN];
priority_queue<pii,vector<pii>,greater<pii> > Q;
queue<int> Q1;
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
sort(a,a+n);
int tmp=1;
for(int i=0;i<n;i++){
for (int j=tmp;j<=a[i].first;j++)Q.push(make_pair(0,j));
for (int j=0;j<a[i].second;j++){
pii P=Q.top();Q.pop();
s[P.second]++;
Q1.push(P.second);
}
while(!Q1.empty()){
int x=Q1.front();Q1.pop();
Q.push(make_pair(s[x],x));
}
tmp=a[i].first+1;
}
long long ans=0;
for (int i=1;i<tmp;i++)ans+=s[i]*(s[i]-1)/2;
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |