# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20209 | wjdtmddnr24 | 컬러볼 (KOI15_ball) | C++98 | 136 ms | 5 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 201505
int n, s[N], total;
int size[N], color[N], cnt;
struct A{
int size, color, index;
int sum;
}a[N];
bool comp(A x, A y){
return x.size < y.size;
}
bool comp2(A x, A y){
return x.index < y.index;
}
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
scanf("%d %d", &a[i].color, &a[i].size);
a[i].index = i;
}
sort(a + 1, a + n + 1, comp);
for (int i = 1; i <= n; i++)
{
if (a[i - 1].size < a[i].size)
{
for (int j = 1; j <= cnt; j++)
{
s[color[j]] += size[j];
total += size[j];
}
cnt = 0;
}
cnt++;
size[cnt] = a[i].size;
color[cnt] = a[i].color;
a[i].sum = total - s[a[i].color];
}
sort(a + 1, a + n + 1, comp2);
for (int i = 1; i <= n; i++)
{
printf("%d ", a[i].sum);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |