답안 #955941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955941 2024-03-31T17:49:53 Z YassirSalama Team Contest (JOI22_team) C++17
8 / 100
2000 ms 8556 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()
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
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;
    unordered_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(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:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int j=0;j<=a.size()-1;j++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 16 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 12 ms 344 KB Output is correct
17 Correct 15 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 16 ms 604 KB Output is correct
20 Correct 22 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 13 ms 348 KB Output is correct
25 Correct 12 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 16 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 12 ms 344 KB Output is correct
17 Correct 15 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 16 ms 604 KB Output is correct
20 Correct 22 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 13 ms 348 KB Output is correct
25 Correct 12 ms 504 KB Output is correct
26 Execution timed out 2101 ms 1564 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 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 2089 ms 8556 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 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 2089 ms 8556 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 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 2089 ms 8556 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 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 2089 ms 8556 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 0 ms 348 KB Output is correct
8 Correct 0 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 16 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 12 ms 344 KB Output is correct
17 Correct 15 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 16 ms 604 KB Output is correct
20 Correct 22 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 13 ms 348 KB Output is correct
25 Correct 12 ms 504 KB Output is correct
26 Execution timed out 2101 ms 1564 KB Time limit exceeded
27 Halted 0 ms 0 KB -