답안 #567782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567782 2022-05-24T07:46:50 Z dantoh000 Team Contest (JOI22_team) C++14
64 / 100
2000 ms 5164 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef tuple<int, int, int> iii;
int n;
vector<iii> v;
vector<ii> topush;
vector<ii> P;
vector<int> topush2;
map<int,ii> XX;
void add(int x, int y){
    if (XX.count(x) == 0){
        XX[x] = {y,y};
    }
    else{
        XX[x] = {min(XX[x].first, y), max(XX[x].second,y)};
    }
}
int query(int x, int y){
    int mx = -1;
    int mx2 = -1;
    int ans = -1;
    for (auto X : XX){
        int b, mxc, mnc;
        ii it;
        tie(b,it) = X;
        tie(mnc, mxc) = it;

        mx = max(mx, mx2);
        mx2 = mxc;
        if (b > x && mx > y && mx > mnc){
            ans = max(ans, b+mx);
        }
    }
    //printf("query %d %d = %d\n",x,y,ans);
    return ans;
}

int main(){
    scanf("%d",&n);
    for (int i = 0,a,b,c; i < n; i++){
        scanf("%d%d%d",&a,&b,&c);
        v.emplace_back(a,b,c);
    }
    sort(v.begin(),v.end());
    int last = -1;
    int ans = -1;
    for (auto x : v){
        int a,b,c;
        tie(a,b,c) = x;
        if (a != last){
            for (auto X : topush){
                add(X.first, X.second);
            }
            topush.clear();
            last = a;
        }
        topush.push_back({b,c});
        int CC = query(b,c);
        if (CC != -1) ans = max(ans, CC+a);
        ///printf("%d %d %d\n",a,b,c);
    }
    printf("%d",ans);
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
team.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%d%d%d",&a,&b,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 83 ms 480 KB Output is correct
27 Correct 55 ms 452 KB Output is correct
28 Correct 52 ms 456 KB Output is correct
29 Correct 43 ms 432 KB Output is correct
30 Correct 24 ms 400 KB Output is correct
31 Correct 26 ms 400 KB Output is correct
32 Correct 9 ms 396 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 65 ms 468 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 19 ms 392 KB Output is correct
38 Correct 17 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 48 ms 3420 KB Output is correct
12 Correct 30 ms 2244 KB Output is correct
13 Correct 37 ms 2696 KB Output is correct
14 Correct 45 ms 3484 KB Output is correct
15 Correct 40 ms 3908 KB Output is correct
16 Correct 40 ms 5164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 48 ms 3420 KB Output is correct
12 Correct 30 ms 2244 KB Output is correct
13 Correct 37 ms 2696 KB Output is correct
14 Correct 45 ms 3484 KB Output is correct
15 Correct 40 ms 3908 KB Output is correct
16 Correct 40 ms 5164 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 3484 KB Output is correct
23 Correct 60 ms 3480 KB Output is correct
24 Correct 44 ms 1996 KB Output is correct
25 Correct 72 ms 3500 KB Output is correct
26 Correct 43 ms 3956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 48 ms 3420 KB Output is correct
12 Correct 30 ms 2244 KB Output is correct
13 Correct 37 ms 2696 KB Output is correct
14 Correct 45 ms 3484 KB Output is correct
15 Correct 40 ms 3908 KB Output is correct
16 Correct 40 ms 5164 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 3484 KB Output is correct
23 Correct 60 ms 3480 KB Output is correct
24 Correct 44 ms 1996 KB Output is correct
25 Correct 72 ms 3500 KB Output is correct
26 Correct 43 ms 3956 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 7 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 283 ms 3440 KB Output is correct
35 Correct 253 ms 3388 KB Output is correct
36 Correct 252 ms 3432 KB Output is correct
37 Correct 262 ms 3452 KB Output is correct
38 Correct 46 ms 3892 KB Output is correct
39 Correct 25 ms 3144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 48 ms 3420 KB Output is correct
12 Correct 30 ms 2244 KB Output is correct
13 Correct 37 ms 2696 KB Output is correct
14 Correct 45 ms 3484 KB Output is correct
15 Correct 40 ms 3908 KB Output is correct
16 Correct 40 ms 5164 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 66 ms 3484 KB Output is correct
23 Correct 60 ms 3480 KB Output is correct
24 Correct 44 ms 1996 KB Output is correct
25 Correct 72 ms 3500 KB Output is correct
26 Correct 43 ms 3956 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 7 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 283 ms 3440 KB Output is correct
35 Correct 253 ms 3388 KB Output is correct
36 Correct 252 ms 3432 KB Output is correct
37 Correct 262 ms 3452 KB Output is correct
38 Correct 46 ms 3892 KB Output is correct
39 Correct 25 ms 3144 KB Output is correct
40 Correct 23 ms 400 KB Output is correct
41 Correct 27 ms 388 KB Output is correct
42 Correct 15 ms 340 KB Output is correct
43 Correct 17 ms 420 KB Output is correct
44 Execution timed out 2079 ms 3392 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 83 ms 480 KB Output is correct
27 Correct 55 ms 452 KB Output is correct
28 Correct 52 ms 456 KB Output is correct
29 Correct 43 ms 432 KB Output is correct
30 Correct 24 ms 400 KB Output is correct
31 Correct 26 ms 400 KB Output is correct
32 Correct 9 ms 396 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 65 ms 468 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 19 ms 392 KB Output is correct
38 Correct 17 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 48 ms 3420 KB Output is correct
51 Correct 30 ms 2244 KB Output is correct
52 Correct 37 ms 2696 KB Output is correct
53 Correct 45 ms 3484 KB Output is correct
54 Correct 40 ms 3908 KB Output is correct
55 Correct 40 ms 5164 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 66 ms 3484 KB Output is correct
62 Correct 60 ms 3480 KB Output is correct
63 Correct 44 ms 1996 KB Output is correct
64 Correct 72 ms 3500 KB Output is correct
65 Correct 43 ms 3956 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 7 ms 340 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 283 ms 3440 KB Output is correct
74 Correct 253 ms 3388 KB Output is correct
75 Correct 252 ms 3432 KB Output is correct
76 Correct 262 ms 3452 KB Output is correct
77 Correct 46 ms 3892 KB Output is correct
78 Correct 25 ms 3144 KB Output is correct
79 Correct 23 ms 400 KB Output is correct
80 Correct 27 ms 388 KB Output is correct
81 Correct 15 ms 340 KB Output is correct
82 Correct 17 ms 420 KB Output is correct
83 Execution timed out 2079 ms 3392 KB Time limit exceeded
84 Halted 0 ms 0 KB -