-
Notifications
You must be signed in to change notification settings - Fork 0
/
J. The Power of the Dark Side - 2.cpp
55 lines (35 loc) · 1.08 KB
/
J. The Power of the Dark Side - 2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;
bool possible(ll x, ll chute) {
return (x >= chute + 2);
}
int main() { _
ll n;
cin >> n;
vector<vector<ll>> jedis(n, vector<ll>(3));
vector<ll> defenses(n);
for (ll i = 0; i < n; i++)
{
cin >> jedis[i][0] >> jedis[i][1] >> jedis[i][2];
defenses[i] = min(jedis[i][0], jedis[i][1]) +
min(max(jedis[i][0], jedis[i][1]), jedis[i][2]);
}
sort(defenses.begin(), defenses.end());
for (ll i = 0; i < n; i++)
{
ll atack = jedis[i][0] + jedis[i][1] + jedis[i][2];
ll left = 0, right = n;
while (left < right)
{
ll middle = (left + right + 1) / 2;
if (possible(atack, defenses[middle - 1])) left = middle;
else right = middle - 1;
}
ll defense = atack - max(max(jedis[i][0],jedis[i][1]), jedis[i][2]);
if(possible(atack, defense)) left--;
cout << left << ' ';
}
cout << '\n';
}