답안 #591879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591879 2022-07-08T05:40:25 Z 반딧불(#8422) Team Contest (JOI22_team) C++17
9 / 100
2000 ms 464 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct segTree{
    int tree[600002];

    void init(int i, int l, int r){
        tree[i] = -1e9;
        if(l==r) return;
        int m = (l+r)>>1;
        init(i*2, l, m), init(i*2+1, m+1, r);
    }

    void update(int i, int l, int r, int x, int v){
        if(l==r){
            tree[i] = max(tree[i], v);
            return;
        }
        int m = (l+r)>>1;
        if(x<=m) update(i*2, l, m, x, v);
        else update(i*2+1, m+1, r, x, v);
        tree[i] = max(tree[i*2], tree[i*2+1]);
    }

    int query(int i, int l, int r, int s, int e){
        if(r<s || e<l) return -1e9;
        if(s<=l && r<=e) return tree[i];
        int m = (l+r)>>1;
        return max(query(i*2, l, m, s, e), query(i*2+1, m+1, r, s, e));
    }
} tree;

int n;
int x[150002], y[150002], z[150002];
int yIdx[150002];
int mark[22][22][22];
int ans = -1;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d %d %d", &x[i], &y[i], &z[i]);
        if(mark[x[i]][y[i]][z[i]]) n--, i--;
        else mark[x[i]][y[i]][z[i]] = 1;
    }
    vector<int> vec (y+1, y+n+1);
    sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for(int i=1; i<=n; i++) yIdx[i] = lower_bound(vec.begin(), vec.end(), y[i]) - vec.begin() + 1;

    for(int i=1; i<=n; i++){
        tree.init(1, 1, n);
        for(int j=1; j<=n; j++){
            if(x[i] > x[j]) tree.update(1, 1, n, yIdx[j], z[j]);
        }
        for(int j=1; j<=n; j++){
            if(x[i] <= x[j] || y[i] >= y[j]) continue;
            int tmp = tree.query(1, 1, n, 1, yIdx[j]-1);
            if(z[i] < tmp && z[j] < tmp) ans = max(ans, x[i] + y[j] + tree.query(1, 1, n, 1, yIdx[j]-1));
        }
    }
    printf("%d", ans);
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
team.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         scanf("%d %d %d", &x[i], &y[i], &z[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 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 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 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 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 340 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 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 336 KB Output is correct
12 Correct 20 ms 340 KB Output is correct
13 Correct 24 ms 340 KB Output is correct
14 Correct 29 ms 212 KB Output is correct
15 Correct 27 ms 212 KB Output is correct
16 Correct 26 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 340 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 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 336 KB Output is correct
12 Correct 20 ms 340 KB Output is correct
13 Correct 24 ms 340 KB Output is correct
14 Correct 29 ms 212 KB Output is correct
15 Correct 27 ms 212 KB Output is correct
16 Correct 26 ms 316 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 103 ms 392 KB Output is correct
22 Execution timed out 2080 ms 464 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 340 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 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 336 KB Output is correct
12 Correct 20 ms 340 KB Output is correct
13 Correct 24 ms 340 KB Output is correct
14 Correct 29 ms 212 KB Output is correct
15 Correct 27 ms 212 KB Output is correct
16 Correct 26 ms 316 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 103 ms 392 KB Output is correct
22 Execution timed out 2080 ms 464 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 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 340 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 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 30 ms 336 KB Output is correct
12 Correct 20 ms 340 KB Output is correct
13 Correct 24 ms 340 KB Output is correct
14 Correct 29 ms 212 KB Output is correct
15 Correct 27 ms 212 KB Output is correct
16 Correct 26 ms 316 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 103 ms 392 KB Output is correct
22 Execution timed out 2080 ms 464 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 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 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -