답안 #567740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567740 2022-05-24T06:17:52 Z dantoh000 Team Contest (JOI22_team) C++14
37 / 100
2000 ms 3976 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;
void add(int x, int y){
    //printf("adding %d\n",x,y);
    P.push_back({x,y});
}
int query(int x, int y){

    sort(P.begin(), P.end());
    int last = -1;
    int mx = -1;
    int mx2 = -1;
    int ans = -1;
    for (auto X : P){
        int b,c;
        tie(b,c) = X;
        if (b != last){
            mx = max(mx, mx2);
            mx2 = -1;
            last = b;
        }
        mx2 = max(mx2, c);
        if (b > x && mx > y && mx > c){
            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:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
team.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 300 KB Output is correct
19 Correct 2 ms 292 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 300 KB Output is correct
19 Correct 2 ms 292 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 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 332 ms 472 KB Output is correct
27 Correct 264 ms 572 KB Output is correct
28 Correct 291 ms 572 KB Output is correct
29 Correct 213 ms 464 KB Output is correct
30 Correct 111 ms 384 KB Output is correct
31 Correct 239 ms 460 KB Output is correct
32 Correct 168 ms 436 KB Output is correct
33 Correct 38 ms 452 KB Output is correct
34 Correct 147 ms 468 KB Output is correct
35 Correct 9 ms 304 KB Output is correct
36 Correct 9 ms 340 KB Output is correct
37 Correct 186 ms 448 KB Output is correct
38 Correct 198 ms 428 KB Output is correct
39 Correct 40 ms 340 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2062 ms 3976 KB Time limit exceeded
12 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2062 ms 3976 KB Time limit exceeded
12 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2062 ms 3976 KB Time limit exceeded
12 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2062 ms 3976 KB Time limit exceeded
12 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 300 KB Output is correct
19 Correct 2 ms 292 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 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 332 ms 472 KB Output is correct
27 Correct 264 ms 572 KB Output is correct
28 Correct 291 ms 572 KB Output is correct
29 Correct 213 ms 464 KB Output is correct
30 Correct 111 ms 384 KB Output is correct
31 Correct 239 ms 460 KB Output is correct
32 Correct 168 ms 436 KB Output is correct
33 Correct 38 ms 452 KB Output is correct
34 Correct 147 ms 468 KB Output is correct
35 Correct 9 ms 304 KB Output is correct
36 Correct 9 ms 340 KB Output is correct
37 Correct 186 ms 448 KB Output is correct
38 Correct 198 ms 428 KB Output is correct
39 Correct 40 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Execution timed out 2062 ms 3976 KB Time limit exceeded
51 Halted 0 ms 0 KB -