답안 #709860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709860 2023-03-14T17:35:31 Z urosk Team Contest (JOI22_team) C++14
100 / 100
559 ms 74860 KB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}

#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
//using namespace __gnu_pbds;
/*
ll add(ll x,ll y){
    x+=y;
    if(x<0){
        x%=mod;
        x+=mod;
    }else{
        if(x>=mod) x%=mod;
    }
    return x;
}
ll mul(ll a,ll b){
	ll ans = (a*b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
typedef tree<int,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
    return uniform_int_distribution<ll>(l,r)(rng);
}
*/
#define maxn 1500005
ll n;
vector<ll> a[maxn];
set<pll> s[4];
bool bad[maxn];
void tc(){
    cin >> n;
    for(ll i = 1;i<=n;i++){
        a[i].resize(4);
        for(ll j = 1;j<=3;j++){
            cin >> a[i][j];
            s[j].insert({a[i][j],i});
        }
    }
    while(s[1].size()&&s[2].size()&&s[3].size()){
        bool moe = 1;
        for(ll i = 1;i<=3;i++){
            ll k = prev(s[i].end())->sc;
            ll val = prev(s[i].end())->fi;
            for(ll j = 1;j<=3;j++){
                if(i==j) continue;
                if(a[k][j]>=prev(s[j].end())->fi){
                    moe = 0;
                    bad[k] = 1;
                }
            }
        }
        if(moe){
            ll ans = 0;
            for(ll i = 1;i<=3;i++) ans+=prev(s[i].end())->fi;
            cout<<ans<<endl;
            return;
        }
        for(ll i = 1;i<=3;i++){
            ll k = prev(s[i].end())->sc;
            if(bad[k]) s[i].erase(prev(s[i].end()));
        }
    }
    cout<<-1<<endl;
}
int main(){
	daj_mi_malo_vremena
    int t; t = 1;
    while(t--){
        tc();
    }
	return 0;
}

Compilation message

team.cpp: In function 'void tc()':
team.cpp:65:16: warning: unused variable 'val' [-Wunused-variable]
   65 |             ll val = prev(s[i].end())->fi;
      |                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 35480 KB Output is correct
2 Correct 19 ms 35444 KB Output is correct
3 Correct 20 ms 35668 KB Output is correct
4 Correct 19 ms 35560 KB Output is correct
5 Correct 21 ms 35524 KB Output is correct
6 Correct 19 ms 35560 KB Output is correct
7 Correct 22 ms 35552 KB Output is correct
8 Correct 23 ms 35540 KB Output is correct
9 Correct 21 ms 35504 KB Output is correct
10 Correct 21 ms 35500 KB Output is correct
11 Correct 19 ms 35540 KB Output is correct
12 Correct 19 ms 35552 KB Output is correct
13 Correct 24 ms 35536 KB Output is correct
14 Correct 24 ms 35532 KB Output is correct
15 Correct 19 ms 35564 KB Output is correct
16 Correct 20 ms 35560 KB Output is correct
17 Correct 23 ms 35616 KB Output is correct
18 Correct 23 ms 35556 KB Output is correct
19 Correct 33 ms 35528 KB Output is correct
20 Correct 19 ms 35612 KB Output is correct
21 Correct 19 ms 35560 KB Output is correct
22 Correct 19 ms 35540 KB Output is correct
23 Correct 21 ms 35540 KB Output is correct
24 Correct 24 ms 35556 KB Output is correct
25 Correct 18 ms 35608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 35480 KB Output is correct
2 Correct 19 ms 35444 KB Output is correct
3 Correct 20 ms 35668 KB Output is correct
4 Correct 19 ms 35560 KB Output is correct
5 Correct 21 ms 35524 KB Output is correct
6 Correct 19 ms 35560 KB Output is correct
7 Correct 22 ms 35552 KB Output is correct
8 Correct 23 ms 35540 KB Output is correct
9 Correct 21 ms 35504 KB Output is correct
10 Correct 21 ms 35500 KB Output is correct
11 Correct 19 ms 35540 KB Output is correct
12 Correct 19 ms 35552 KB Output is correct
13 Correct 24 ms 35536 KB Output is correct
14 Correct 24 ms 35532 KB Output is correct
15 Correct 19 ms 35564 KB Output is correct
16 Correct 20 ms 35560 KB Output is correct
17 Correct 23 ms 35616 KB Output is correct
18 Correct 23 ms 35556 KB Output is correct
19 Correct 33 ms 35528 KB Output is correct
20 Correct 19 ms 35612 KB Output is correct
21 Correct 19 ms 35560 KB Output is correct
22 Correct 19 ms 35540 KB Output is correct
23 Correct 21 ms 35540 KB Output is correct
24 Correct 24 ms 35556 KB Output is correct
25 Correct 18 ms 35608 KB Output is correct
26 Correct 24 ms 36460 KB Output is correct
27 Correct 23 ms 36456 KB Output is correct
28 Correct 25 ms 36476 KB Output is correct
29 Correct 26 ms 36500 KB Output is correct
30 Correct 24 ms 36204 KB Output is correct
31 Correct 28 ms 36464 KB Output is correct
32 Correct 27 ms 36452 KB Output is correct
33 Correct 29 ms 36436 KB Output is correct
34 Correct 27 ms 36536 KB Output is correct
35 Correct 23 ms 35768 KB Output is correct
36 Correct 23 ms 35740 KB Output is correct
37 Correct 26 ms 36480 KB Output is correct
38 Correct 28 ms 36440 KB Output is correct
39 Correct 26 ms 35932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 35620 KB Output is correct
2 Correct 21 ms 35552 KB Output is correct
3 Correct 24 ms 35540 KB Output is correct
4 Correct 21 ms 35540 KB Output is correct
5 Correct 21 ms 35484 KB Output is correct
6 Correct 23 ms 35448 KB Output is correct
7 Correct 24 ms 35492 KB Output is correct
8 Correct 23 ms 35556 KB Output is correct
9 Correct 22 ms 35552 KB Output is correct
10 Correct 22 ms 35528 KB Output is correct
11 Correct 243 ms 71532 KB Output is correct
12 Correct 156 ms 59580 KB Output is correct
13 Correct 164 ms 65320 KB Output is correct
14 Correct 244 ms 71688 KB Output is correct
15 Correct 202 ms 71788 KB Output is correct
16 Correct 195 ms 71724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 35620 KB Output is correct
2 Correct 21 ms 35552 KB Output is correct
3 Correct 24 ms 35540 KB Output is correct
4 Correct 21 ms 35540 KB Output is correct
5 Correct 21 ms 35484 KB Output is correct
6 Correct 23 ms 35448 KB Output is correct
7 Correct 24 ms 35492 KB Output is correct
8 Correct 23 ms 35556 KB Output is correct
9 Correct 22 ms 35552 KB Output is correct
10 Correct 22 ms 35528 KB Output is correct
11 Correct 243 ms 71532 KB Output is correct
12 Correct 156 ms 59580 KB Output is correct
13 Correct 164 ms 65320 KB Output is correct
14 Correct 244 ms 71688 KB Output is correct
15 Correct 202 ms 71788 KB Output is correct
16 Correct 195 ms 71724 KB Output is correct
17 Correct 23 ms 35540 KB Output is correct
18 Correct 21 ms 35544 KB Output is correct
19 Correct 24 ms 35504 KB Output is correct
20 Correct 22 ms 35548 KB Output is correct
21 Correct 24 ms 36016 KB Output is correct
22 Correct 289 ms 71892 KB Output is correct
23 Correct 229 ms 71084 KB Output is correct
24 Correct 195 ms 61820 KB Output is correct
25 Correct 270 ms 71968 KB Output is correct
26 Correct 194 ms 71796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 35620 KB Output is correct
2 Correct 21 ms 35552 KB Output is correct
3 Correct 24 ms 35540 KB Output is correct
4 Correct 21 ms 35540 KB Output is correct
5 Correct 21 ms 35484 KB Output is correct
6 Correct 23 ms 35448 KB Output is correct
7 Correct 24 ms 35492 KB Output is correct
8 Correct 23 ms 35556 KB Output is correct
9 Correct 22 ms 35552 KB Output is correct
10 Correct 22 ms 35528 KB Output is correct
11 Correct 243 ms 71532 KB Output is correct
12 Correct 156 ms 59580 KB Output is correct
13 Correct 164 ms 65320 KB Output is correct
14 Correct 244 ms 71688 KB Output is correct
15 Correct 202 ms 71788 KB Output is correct
16 Correct 195 ms 71724 KB Output is correct
17 Correct 23 ms 35540 KB Output is correct
18 Correct 21 ms 35544 KB Output is correct
19 Correct 24 ms 35504 KB Output is correct
20 Correct 22 ms 35548 KB Output is correct
21 Correct 24 ms 36016 KB Output is correct
22 Correct 289 ms 71892 KB Output is correct
23 Correct 229 ms 71084 KB Output is correct
24 Correct 195 ms 61820 KB Output is correct
25 Correct 270 ms 71968 KB Output is correct
26 Correct 194 ms 71796 KB Output is correct
27 Correct 25 ms 35512 KB Output is correct
28 Correct 21 ms 35632 KB Output is correct
29 Correct 19 ms 35584 KB Output is correct
30 Correct 24 ms 35524 KB Output is correct
31 Correct 24 ms 36496 KB Output is correct
32 Correct 21 ms 35748 KB Output is correct
33 Correct 26 ms 35648 KB Output is correct
34 Correct 362 ms 70496 KB Output is correct
35 Correct 371 ms 68960 KB Output is correct
36 Correct 391 ms 72320 KB Output is correct
37 Correct 417 ms 72228 KB Output is correct
38 Correct 237 ms 71684 KB Output is correct
39 Correct 122 ms 57672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 35620 KB Output is correct
2 Correct 21 ms 35552 KB Output is correct
3 Correct 24 ms 35540 KB Output is correct
4 Correct 21 ms 35540 KB Output is correct
5 Correct 21 ms 35484 KB Output is correct
6 Correct 23 ms 35448 KB Output is correct
7 Correct 24 ms 35492 KB Output is correct
8 Correct 23 ms 35556 KB Output is correct
9 Correct 22 ms 35552 KB Output is correct
10 Correct 22 ms 35528 KB Output is correct
11 Correct 243 ms 71532 KB Output is correct
12 Correct 156 ms 59580 KB Output is correct
13 Correct 164 ms 65320 KB Output is correct
14 Correct 244 ms 71688 KB Output is correct
15 Correct 202 ms 71788 KB Output is correct
16 Correct 195 ms 71724 KB Output is correct
17 Correct 23 ms 35540 KB Output is correct
18 Correct 21 ms 35544 KB Output is correct
19 Correct 24 ms 35504 KB Output is correct
20 Correct 22 ms 35548 KB Output is correct
21 Correct 24 ms 36016 KB Output is correct
22 Correct 289 ms 71892 KB Output is correct
23 Correct 229 ms 71084 KB Output is correct
24 Correct 195 ms 61820 KB Output is correct
25 Correct 270 ms 71968 KB Output is correct
26 Correct 194 ms 71796 KB Output is correct
27 Correct 25 ms 35512 KB Output is correct
28 Correct 21 ms 35632 KB Output is correct
29 Correct 19 ms 35584 KB Output is correct
30 Correct 24 ms 35524 KB Output is correct
31 Correct 24 ms 36496 KB Output is correct
32 Correct 21 ms 35748 KB Output is correct
33 Correct 26 ms 35648 KB Output is correct
34 Correct 362 ms 70496 KB Output is correct
35 Correct 371 ms 68960 KB Output is correct
36 Correct 391 ms 72320 KB Output is correct
37 Correct 417 ms 72228 KB Output is correct
38 Correct 237 ms 71684 KB Output is correct
39 Correct 122 ms 57672 KB Output is correct
40 Correct 24 ms 36184 KB Output is correct
41 Correct 24 ms 36512 KB Output is correct
42 Correct 27 ms 36472 KB Output is correct
43 Correct 23 ms 36424 KB Output is correct
44 Correct 559 ms 72756 KB Output is correct
45 Correct 527 ms 73040 KB Output is correct
46 Correct 461 ms 73036 KB Output is correct
47 Correct 547 ms 73056 KB Output is correct
48 Correct 315 ms 72896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 35480 KB Output is correct
2 Correct 19 ms 35444 KB Output is correct
3 Correct 20 ms 35668 KB Output is correct
4 Correct 19 ms 35560 KB Output is correct
5 Correct 21 ms 35524 KB Output is correct
6 Correct 19 ms 35560 KB Output is correct
7 Correct 22 ms 35552 KB Output is correct
8 Correct 23 ms 35540 KB Output is correct
9 Correct 21 ms 35504 KB Output is correct
10 Correct 21 ms 35500 KB Output is correct
11 Correct 19 ms 35540 KB Output is correct
12 Correct 19 ms 35552 KB Output is correct
13 Correct 24 ms 35536 KB Output is correct
14 Correct 24 ms 35532 KB Output is correct
15 Correct 19 ms 35564 KB Output is correct
16 Correct 20 ms 35560 KB Output is correct
17 Correct 23 ms 35616 KB Output is correct
18 Correct 23 ms 35556 KB Output is correct
19 Correct 33 ms 35528 KB Output is correct
20 Correct 19 ms 35612 KB Output is correct
21 Correct 19 ms 35560 KB Output is correct
22 Correct 19 ms 35540 KB Output is correct
23 Correct 21 ms 35540 KB Output is correct
24 Correct 24 ms 35556 KB Output is correct
25 Correct 18 ms 35608 KB Output is correct
26 Correct 24 ms 36460 KB Output is correct
27 Correct 23 ms 36456 KB Output is correct
28 Correct 25 ms 36476 KB Output is correct
29 Correct 26 ms 36500 KB Output is correct
30 Correct 24 ms 36204 KB Output is correct
31 Correct 28 ms 36464 KB Output is correct
32 Correct 27 ms 36452 KB Output is correct
33 Correct 29 ms 36436 KB Output is correct
34 Correct 27 ms 36536 KB Output is correct
35 Correct 23 ms 35768 KB Output is correct
36 Correct 23 ms 35740 KB Output is correct
37 Correct 26 ms 36480 KB Output is correct
38 Correct 28 ms 36440 KB Output is correct
39 Correct 26 ms 35932 KB Output is correct
40 Correct 24 ms 35620 KB Output is correct
41 Correct 21 ms 35552 KB Output is correct
42 Correct 24 ms 35540 KB Output is correct
43 Correct 21 ms 35540 KB Output is correct
44 Correct 21 ms 35484 KB Output is correct
45 Correct 23 ms 35448 KB Output is correct
46 Correct 24 ms 35492 KB Output is correct
47 Correct 23 ms 35556 KB Output is correct
48 Correct 22 ms 35552 KB Output is correct
49 Correct 22 ms 35528 KB Output is correct
50 Correct 243 ms 71532 KB Output is correct
51 Correct 156 ms 59580 KB Output is correct
52 Correct 164 ms 65320 KB Output is correct
53 Correct 244 ms 71688 KB Output is correct
54 Correct 202 ms 71788 KB Output is correct
55 Correct 195 ms 71724 KB Output is correct
56 Correct 23 ms 35540 KB Output is correct
57 Correct 21 ms 35544 KB Output is correct
58 Correct 24 ms 35504 KB Output is correct
59 Correct 22 ms 35548 KB Output is correct
60 Correct 24 ms 36016 KB Output is correct
61 Correct 289 ms 71892 KB Output is correct
62 Correct 229 ms 71084 KB Output is correct
63 Correct 195 ms 61820 KB Output is correct
64 Correct 270 ms 71968 KB Output is correct
65 Correct 194 ms 71796 KB Output is correct
66 Correct 25 ms 35512 KB Output is correct
67 Correct 21 ms 35632 KB Output is correct
68 Correct 19 ms 35584 KB Output is correct
69 Correct 24 ms 35524 KB Output is correct
70 Correct 24 ms 36496 KB Output is correct
71 Correct 21 ms 35748 KB Output is correct
72 Correct 26 ms 35648 KB Output is correct
73 Correct 362 ms 70496 KB Output is correct
74 Correct 371 ms 68960 KB Output is correct
75 Correct 391 ms 72320 KB Output is correct
76 Correct 417 ms 72228 KB Output is correct
77 Correct 237 ms 71684 KB Output is correct
78 Correct 122 ms 57672 KB Output is correct
79 Correct 24 ms 36184 KB Output is correct
80 Correct 24 ms 36512 KB Output is correct
81 Correct 27 ms 36472 KB Output is correct
82 Correct 23 ms 36424 KB Output is correct
83 Correct 559 ms 72756 KB Output is correct
84 Correct 527 ms 73040 KB Output is correct
85 Correct 461 ms 73036 KB Output is correct
86 Correct 547 ms 73056 KB Output is correct
87 Correct 315 ms 72896 KB Output is correct
88 Correct 485 ms 74668 KB Output is correct
89 Correct 466 ms 74760 KB Output is correct
90 Correct 511 ms 74776 KB Output is correct
91 Correct 506 ms 74700 KB Output is correct
92 Correct 467 ms 73316 KB Output is correct
93 Correct 458 ms 73700 KB Output is correct
94 Correct 481 ms 73468 KB Output is correct
95 Correct 251 ms 74616 KB Output is correct
96 Correct 288 ms 74860 KB Output is correct
97 Correct 174 ms 74828 KB Output is correct
98 Correct 169 ms 73280 KB Output is correct
99 Correct 177 ms 73480 KB Output is correct