답안 #955939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955939 2024-03-31T17:48:43 Z YassirSalama Team Contest (JOI22_team) C++17
8 / 100
2000 ms 9392 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];
});
// for(auto x:v){
//     dbg(x[0],x[1],x[2])
// }
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++){
        if(s.size()==0) break;
        int al=max(v[i][2],a[j].S);
        int x=*s.rbegin();
        // if(i==3){
        //     dbg("here",v[i][2],a[j].S,a[j].F,x,al)
        // }
        // dbg(x,al)
        if(x>al&&a[j].F>v[i][1]) ans=max(ans,x+v[i][0]+a[j].F);
        for(auto x:mp[a[j].F]){
            if(s.find(x)!=s.end()){
                s.erase(s.find(x));
            }
        }
    }
}

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

Compilation message

team.cpp: In function 'int main()':
team.cpp:54: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]
   54 |     for(int j=0;j<=a.size()-1;j++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 18 ms 544 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 15 ms 520 KB Output is correct
19 Correct 14 ms 348 KB Output is correct
20 Correct 12 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 8 ms 540 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 348 KB Output is correct
25 Correct 11 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 18 ms 544 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 15 ms 520 KB Output is correct
19 Correct 14 ms 348 KB Output is correct
20 Correct 12 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 8 ms 540 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 348 KB Output is correct
25 Correct 11 ms 512 KB Output is correct
26 Execution timed out 2065 ms 1884 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 9392 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 9392 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 9392 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Execution timed out 2084 ms 9392 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 18 ms 544 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 16 ms 348 KB Output is correct
18 Correct 15 ms 520 KB Output is correct
19 Correct 14 ms 348 KB Output is correct
20 Correct 12 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 8 ms 540 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 348 KB Output is correct
25 Correct 11 ms 512 KB Output is correct
26 Execution timed out 2065 ms 1884 KB Time limit exceeded
27 Halted 0 ms 0 KB -