Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define nl "\n"
- #define cnl cout << nl;
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define ull unsigned ll
- #define RV return void
- #define sz(x) int(x.size())
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define fixed(n) fixed << setprecision(n)
- #define cin(v) for(auto&x:v) cin >> i;
- #define cout(v) for(auto&x:v) cout << i << " ";
- void files(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- void solve( int test ){
- int n ;
- cin >> n ;
- vector < pair < ll , ll> > p;
- vector < pair < ll , pair < ll , ll > > > v(n);
- for(int i =0 ; i < n ; i++){
- cin >> v[i].fi >> v[i].se.fi >> v[i].se.se;
- ll mx= max({v[i].fi , v[i].se.fi , v[i].se.se})
- , sum = v[i].fi + v[i].se.fi + v[i].se.se - mx;
- p.pb({sum , mx });
- }
- sort(all(p) , [&] ( auto a , auto b){
- if(a.fi == b.fi) {
- return a.se < b.se;
- }
- return a.fi < b.fi;
- });
- auto lwr=[&]( ll sum ){
- int l=0 ,r =n-1 , best =0;
- while(l <= r ){
- int mid = r- (r-l)/2;
- if(p[mid].fi + 2 <= sum){
- best = mid;
- l=mid+1;
- }else{
- r=mid-1;
- }
- }
- return best;
- };
- for(int i =0 ; i < n ;i++){
- ll sum = v[i].fi + v[i].se.fi + v[i].se.se;
- cout << lwr(sum) << " ";
- }
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // files();
- int testCase=1;
- // cin >> testCase ;
- for(int i=1 ; i <= testCase ; i++){
- solve(i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement