# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18037 | gs14004 | 컬러볼 (KOI15_ball) | C++14 | 125 ms | 7188 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 <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
lint ret[200005];
lint sum[200005], fsum;
struct elem{int c, s, i;}a[200005];
int n;
int main(){
scanf("%d",&n);
for(int i=0; i<n; i++){
scanf("%d %d",&a[i].c, &a[i].s);
a[i].i = i;
}
sort(a, a+n, [&](const elem &a, const elem &b){
return a.s < b.s;
});
for(int i=0; i<n; i++){
int e = i;
while(e < n && a[e].s == a[i].s) e++;
for(int j=i; j<e; j++){
ret[a[i].i] = fsum - sum[a[i].c];
}
for(int j=i; j<e; j++){
fsum += a[i].s;
sum[a[i].c] += a[i].s;
}
}
for(int i=0; i<n; i++){
printf("%lld\n",ret[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |