답안 #567781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567781 2022-05-24T07:46:15 Z dantoh000 Team Contest (JOI22_team) C++14
0 / 100
1 ms 212 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(mxc, mnc) = 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 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -