# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18850 | pichulia | 컬러볼 (KOI15_ball) | C++98 | 132 ms | 5000 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<stdio.h>
#include<algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
int n, m = 2000;
piii a[200009];
int s[3000];
int b[200009];
int r[200009];
int main() {
int i, j, k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&a[i].first.second,&a[i].first.first);
s[a[i].first.first] += a[i].first.first;
a[i].second = i;
}
for(i=1; i<=m; i++)
s[i] += s[i-1];
sort(a,a+n);
for(i=0; i<n; i++)
{
r[a[i].second] = s[a[i].first.first - 1] - b[a[i].first.second];
b[a[i].first.second] += a[i].first.first;
}
for(i=0;i<n;i++)
printf("%d\n",r[i]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |