# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
18037 | gs14004 | 컬러볼 (KOI15_ball) | C++14 | 125 ms | 7188 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |