답안 #634514

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634514 2022-08-24T13:52:37 Z Darren0724 Team Contest (JOI22_team) C++17
0 / 100
111 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rz resize
#define pb emplace_back
int INF=1e18;
int mod=1e9+7;
int N=4000;

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),b(n),c(n);
  vector<vector<pii>> v(N+1);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
    v[a[i]].push_back({b[i],c[i]});
  }
  vector<int> rec(N+2),rec1(N+2);
  int ans=-1;
  for(int i=1;i<=N;i++){
    for(auto p:v[i]){
      if(p.second<rec[p.first+1]){
        ans=max(ans,i+rec[p.first+1]+p.first);
      }
    }
    for(auto p:v[i]){
      rec[p.first]=max(rec[p.first],p.second);
    }
    for(int j=2;j<=N;j++){
      rec[j]=max(rec[j],rec[j-1]);
    }
    for(auto p:v[i]){
      if(rec[p.first-1]>p.second){
        rec1[p.first]=max(rec[p.first-1],rec1[p.first]);
      }
    }
    for(int j=2;j<=N;j++){
      rec1[j]=max(rec1[j],rec1[j-1]);
    }
  }
  cout<<ans<<endl;

  return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 468 KB Output is correct
2 Correct 107 ms 448 KB Output is correct
3 Correct 105 ms 460 KB Output is correct
4 Incorrect 105 ms 468 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 468 KB Output is correct
2 Correct 107 ms 448 KB Output is correct
3 Correct 105 ms 460 KB Output is correct
4 Incorrect 105 ms 468 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 468 KB Output is correct
2 Correct 111 ms 468 KB Output is correct
3 Correct 104 ms 468 KB Output is correct
4 Incorrect 104 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 468 KB Output is correct
2 Correct 111 ms 468 KB Output is correct
3 Correct 104 ms 468 KB Output is correct
4 Incorrect 104 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 468 KB Output is correct
2 Correct 111 ms 468 KB Output is correct
3 Correct 104 ms 468 KB Output is correct
4 Incorrect 104 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 468 KB Output is correct
2 Correct 111 ms 468 KB Output is correct
3 Correct 104 ms 468 KB Output is correct
4 Incorrect 104 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 468 KB Output is correct
2 Correct 107 ms 448 KB Output is correct
3 Correct 105 ms 460 KB Output is correct
4 Incorrect 105 ms 468 KB Output isn't correct
5 Halted 0 ms 0 KB -