답안 #955935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955935 2024-03-31T17:43:54 Z YassirSalama Team Contest (JOI22_team) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
#ifdef IOI
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#else
#define dbg(...) 1337;
#endif
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define int long long
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
vector<vector<int>> v(n);
for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    v[i]={a,b,c};
}
sort(all(v),[&](const auto p1,const auto p2){
    if(p1[0]==p2[0]){
        if(p1[1]==p2[1]) return p1[2]>p2[1];
        else return p1[1]>p2[1];
    }
    return p1[0]>p2[0];
});
int ans=0;
for(int i=0;i<n;i++){
    vector<pair<int,int>> a;
    multiset<int> s;
    map<int,vector<int>> mp;
    for(int j=i+1;j<n;j++){
        if(v[j][0]==v[i][0]) continue;
        a.pb({v[j][1],v[j][2]});
        mp[v[j][1]].pb(v[j][2]);
        s.insert(v[j][2]);
    }
    sort(all(a),greater<pair<int,int>>());
    if(a.size()==0) continue;
    for(int j=0;j<=a.size()-1;j++){
        for(auto x:mp[a[j].F]){
            if(s.find(x)!=s.end()){
                s.erase(s.find(x));
            }
        }
        if(s.size()==0) break;
        int al=max(v[i][2],a[j].S);
        int x=*s.rbegin();
        if(x>al&&a[j].F>v[i][1]) ans=max(ans,x+v[i][0]+a[j].F);
    }
}

if(ans==0){
    cout<<-1<<endl;
    return 0;
}
cout<<ans<<endl;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:50:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int j=0;j<=a.size()-1;j++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -