# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51606 | 2018-06-19T05:31:18 Z | baneling100 | 컬러볼 (KOI15_ball) | C++17 | 226 ms | 40848 KB |
#include <cstdio> #include <algorithm> #include <vector> using namespace std; vector<pair<int, int>> Csum[200001]; int N, C[200001], S[200001], Ssum[2001]; int findCsum(int x, int y) { int left = 0, mid, right = Csum[x].size() - 1, value = 0; while(left <= right) { mid = (left + right) / 2; if(y < Csum[x][mid].first) right = mid - 1; else { value = Csum[x][mid].second; left = mid + 1; } } return value; } int main() { int i, j, k; scanf("%d", &N); for(i = 1; i <= N; i++) { scanf("%d %d", &C[i], &S[i]); Csum[C[i]].push_back(make_pair(S[i], S[i])); Ssum[S[i]] += S[i]; } for(i = 1; i <= N; i++) { sort(Csum[i].begin(), Csum[i].end()); k = Csum[i].size(); for(j = 1; j < k; j++) Csum[i][j].second += Csum[i][j - 1].second; } for(i = 1; i <= 2000; i++) Ssum[i] += Ssum[i - 1]; for(i = 1; i <= N; i++) printf("%d\n", Ssum[S[i] - 1] - findCsum(C[i], S[i] - 1)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 148 ms | 17164 KB | Output is correct |
2 | Correct | 152 ms | 19032 KB | Output is correct |
3 | Correct | 179 ms | 21224 KB | Output is correct |
4 | Correct | 157 ms | 23576 KB | Output is correct |
5 | Correct | 194 ms | 25576 KB | Output is correct |
6 | Correct | 10 ms | 25576 KB | Output is correct |
7 | Correct | 11 ms | 25576 KB | Output is correct |
8 | Correct | 11 ms | 25576 KB | Output is correct |
9 | Correct | 10 ms | 25576 KB | Output is correct |
10 | Correct | 9 ms | 25576 KB | Output is correct |
11 | Correct | 130 ms | 25576 KB | Output is correct |
12 | Correct | 190 ms | 25576 KB | Output is correct |
13 | Correct | 134 ms | 26104 KB | Output is correct |
14 | Correct | 133 ms | 27764 KB | Output is correct |
15 | Correct | 126 ms | 28900 KB | Output is correct |
16 | Correct | 175 ms | 31900 KB | Output is correct |
17 | Correct | 226 ms | 34196 KB | Output is correct |
18 | Correct | 170 ms | 36340 KB | Output is correct |
19 | Correct | 177 ms | 38516 KB | Output is correct |
20 | Correct | 177 ms | 40848 KB | Output is correct |