답안 #18854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18854 2016-02-16T03:41:48 Z Namnamseo 컬러볼 (KOI15_ball) C++14
25 / 25
108 ms 4988 KB
#include <cstdio>
#include <algorithm>
using namespace std;
struct ball {
    int size, c, ind;
} d[200010];
int n;
int ans[200010];
int cc[200010];
int main()
{
    scanf("%d",&n);
    int a,b;
    int i;
    for(i=0;i<n;++i){
        scanf("%d%d",&a,&b);
        d[i]={b,a,i};
    }
    sort(d,d+n,[](const ball& a,const ball& b){ return a.size<b.size; });
    int j=0;
    int ss=0;
    for(i=0;i<n;++i){
        while(j<n && d[j].size<d[i].size){
            cc[d[j].c]+=d[j].size;
            ss+=d[j].size;
            ++j;
        }
        ans[d[i].ind] = ss-cc[d[i].c];
    }
    for(i=0;i<n;++i) printf("%d\n",ans[i]);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 4988 KB Output is correct
2 Correct 97 ms 4988 KB Output is correct
3 Correct 101 ms 4988 KB Output is correct
4 Correct 91 ms 4988 KB Output is correct
5 Correct 81 ms 4988 KB Output is correct
6 Correct 0 ms 4988 KB Output is correct
7 Correct 2 ms 4988 KB Output is correct
8 Correct 0 ms 4988 KB Output is correct
9 Correct 2 ms 4988 KB Output is correct
10 Correct 0 ms 4988 KB Output is correct
11 Correct 107 ms 4988 KB Output is correct
12 Correct 95 ms 4988 KB Output is correct
13 Correct 80 ms 4988 KB Output is correct
14 Correct 68 ms 4988 KB Output is correct
15 Correct 74 ms 4988 KB Output is correct
16 Correct 108 ms 4988 KB Output is correct
17 Correct 73 ms 4988 KB Output is correct
18 Correct 83 ms 4988 KB Output is correct
19 Correct 76 ms 4988 KB Output is correct
20 Correct 65 ms 4988 KB Output is correct