# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51606 | baneling100 | 컬러볼 (KOI15_ball) | C++17 | 226 ms | 40848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |