# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
544655 |
2022-04-02T14:15:17 Z |
pokmui9909 |
컬러볼 (KOI15_ball) |
C++17 |
|
79 ms |
12212 KB |
#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 |
1 |
Correct |
73 ms |
12212 KB |
Output is correct |
2 |
Correct |
74 ms |
12008 KB |
Output is correct |
3 |
Correct |
79 ms |
11996 KB |
Output is correct |
4 |
Correct |
72 ms |
11988 KB |
Output is correct |
5 |
Correct |
71 ms |
12008 KB |
Output is correct |
6 |
Correct |
2 ms |
596 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
67 ms |
9748 KB |
Output is correct |
12 |
Correct |
68 ms |
9720 KB |
Output is correct |
13 |
Correct |
64 ms |
9816 KB |
Output is correct |
14 |
Correct |
63 ms |
9808 KB |
Output is correct |
15 |
Correct |
62 ms |
9788 KB |
Output is correct |
16 |
Correct |
68 ms |
10800 KB |
Output is correct |
17 |
Correct |
66 ms |
10824 KB |
Output is correct |
18 |
Correct |
67 ms |
11400 KB |
Output is correct |
19 |
Correct |
71 ms |
11708 KB |
Output is correct |
20 |
Correct |
72 ms |
12076 KB |
Output is correct |