Submission #18850

#TimeUsernameProblemLanguageResultExecution timeMemory
18850pichulia컬러볼 (KOI15_ball)C++98
10 / 25
132 ms5000 KiB
#include<stdio.h> #include<algorithm> using namespace std; typedef pair<int, int> pii; typedef pair<pii, int> piii; int n, m = 2000; piii a[200009]; int s[3000]; int b[200009]; int r[200009]; int main() { int i, j, k; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d",&a[i].first.second,&a[i].first.first); s[a[i].first.first] += a[i].first.first; a[i].second = i; } for(i=1; i<=m; i++) s[i] += s[i-1]; sort(a,a+n); for(i=0; i<n; i++) { r[a[i].second] = s[a[i].first.first - 1] - b[a[i].first.second]; b[a[i].first.second] += a[i].first.first; } for(i=0;i<n;i++) printf("%d\n",r[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...