# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544655 | pokmui9909 | 컬러볼 (KOI15_ball) | C++17 | 79 ms | 12212 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll S = 200005;
struct ball
{
ll n, c, s;
bool operator<(const ball &k) const
{
if(s == k.s) return c < k.c;
else return s < k.s;
}
bool operator==(const ball &k) const
{
return (c==k.c && s==k.s);
}
}ar[S];
ll c[S], s[S];
ll ans[S];
int main()
{
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
ll n; cin >> n;
for(ll i = 1; i <= n; i++)
{
cin >> ar[i].c >> ar[i].s;
ar[i].n = i;
}
sort(ar + 1, ar + n + 1);
ll sum = 0;
for(ll i = 1; i <= n; i++)
{
c[ar[i].c] += ar[i].s;
s[ar[i].s] += ar[i].s;
sum += ar[i].s;
ans[ar[i].n] = sum-c[ar[i].c]-s[ar[i].s]+ar[i].s;
if(ar[i - 1] == ar[i])
ans[ar[i].n] = ans[ar[i - 1].n];
}
for(ll i = 1; i <= n; i++)
cout << ans[i] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |