# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20257 | ssunghwan1 | 컬러볼 (KOI15_ball) | C++98 | 453 ms | 5 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
using namespace std;
int tmp = 0;
int cnum;
int color[201505];
int size1[201505];
int s[201505];
int cnt;
int total;
struct haha {
int size;
int color;
int index;
int sum;
}ball[200001];
bool comp(haha x, haha y) { return x.size < y.size; }
bool comp2(haha x, haha y) { return x.index < y.index; }
int main(void) {
std::cin >> cnum;
for (int i = 0; i < cnum;i++) {
std::cin >> ball[i].color;
std::cin >> ball[i].size;
ball[i].index = i;
}
sort(ball, ball + cnum, comp);
s[ball[0].color] += ball[0].size;
total += ball[0].size;
///////////////////////////////////////////////////////////
for (int i = 1; i < cnum;i++) {
s[ball[i].color]+=ball[i].size;
total += ball[i].size;
ball[i].sum = total - s[ball[i].color];
}
///////////////////////////////////////////////////////////////////////
sort(ball, ball + cnum, comp2);
for (int i = 0; i < cnum; i++) {
std::cout<<ball[i].sum<<std::endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |