답안 #724511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724511 2023-04-15T12:33:00 Z MohammadAghil Team Contest (JOI22_team) C++17
9 / 100
73 ms 10556 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define all(x) begin(x), end(x)
#define sz(x) (int)size(x)
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> pp;

void dbg(){
     cerr << endl;
}
template<typename H, typename... T> void dbg(H h, T... t){
     cerr << h << ", ";
     dbg(t...);
}

void IOS(){
     cin.tie(0) -> sync_with_stdio(0);
     #ifndef ONLINE_JUDGE
          // freopen("inp.txt", "r", stdin);
          // freopen("out.txt", "w", stdout);
          #define er(...) cerr << __LINE__ << " <" << #__VA_ARGS__ << ">: ", dbg(__VA_ARGS__)
     #else
          #define er(...) 0
     #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353, maxn = 5e5 + 5, lg = 21, inf = ll(1e9) + 5;

int X = -1, Y = -1;

multiset<pp> s;

void add(int x, int y){
     vector<pp> del;
     auto it = s.lower_bound(pp(x, -1));
     while(it != begin(s)){
          it--;
          if(it->ss <= y) break;
          del.pb(*it);
     }
     auto it2 = s.upper_bound(pp(x, inf));
     while(it2 != end(s)){
          if(it2->ss >= y) break;
          del.pb(*it2);
          it2++;
     }
     if(del.empty()){
          s.insert({x, y});
     } else{
          X = max(X, x), Y = max(Y, y);
          for(auto p: del){
               auto it = s.find(p);
               s.erase(it);
               X = max(X, p.ff), Y = max(Y, p.ss);
          }
     }
}

int main(){ IOS();
     int n; cin >> n;
     map<int, vector<pp>> mp;
     rep(i,0,n){
          int x, y, z; cin >> x >> y >> z;
          mp[z].pb({x, y});
     }
     int ans = -1;
     for(auto[Z, v]: mp){
          for(auto[x, y]: v){
               if(X > x && Y > y){
                    ans = max(ans, Z + X + Y);
               }
          }
          for(auto[x, y]: v){
               add(x, y);
          }
     }
     cout << ans << '\n';
     return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 57 ms 3100 KB Output is correct
12 Correct 39 ms 4044 KB Output is correct
13 Correct 52 ms 8172 KB Output is correct
14 Correct 54 ms 5608 KB Output is correct
15 Correct 52 ms 6880 KB Output is correct
16 Correct 73 ms 10556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 57 ms 3100 KB Output is correct
12 Correct 39 ms 4044 KB Output is correct
13 Correct 52 ms 8172 KB Output is correct
14 Correct 54 ms 5608 KB Output is correct
15 Correct 52 ms 6880 KB Output is correct
16 Correct 73 ms 10556 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 48 ms 2996 KB Output is correct
23 Correct 54 ms 3020 KB Output is correct
24 Incorrect 44 ms 3116 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 57 ms 3100 KB Output is correct
12 Correct 39 ms 4044 KB Output is correct
13 Correct 52 ms 8172 KB Output is correct
14 Correct 54 ms 5608 KB Output is correct
15 Correct 52 ms 6880 KB Output is correct
16 Correct 73 ms 10556 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 48 ms 2996 KB Output is correct
23 Correct 54 ms 3020 KB Output is correct
24 Incorrect 44 ms 3116 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 57 ms 3100 KB Output is correct
12 Correct 39 ms 4044 KB Output is correct
13 Correct 52 ms 8172 KB Output is correct
14 Correct 54 ms 5608 KB Output is correct
15 Correct 52 ms 6880 KB Output is correct
16 Correct 73 ms 10556 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 48 ms 2996 KB Output is correct
23 Correct 54 ms 3020 KB Output is correct
24 Incorrect 44 ms 3116 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Halted 0 ms 0 KB -