Submission #997157

#TimeUsernameProblemLanguageResultExecution timeMemory
997157vladiliusTeam Contest (JOI22_team)C++17
55 / 100
2097 ms14124 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second #define ins insert #define arr3 array<int, 3> int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<arr3> f = {{}}; map<arr3, bool> mp; for (int i = 1; i <= n; i++){ arr3 d; cin>>d[0]>>d[1]>>d[2]; if (mp.find(d) == mp.end()){ f.pb(d); mp[d] = 1; } } n = (int) f.size() - 1; sort(f.begin() + 1, f.end()); vector<int> a(n + 1, -1); int i = 1, out = -1; while (i <= n){ int j = i; while (j <= n && f[i][0] == f[j][0]){ j++; } int mx = -1; for (int t = i; t < j; t++){ for (int k = 1; k < i; k++){ if (a[k] == -1) continue; if (f[k][1] > f[t][1] && (a[k] - f[k][1]) > f[t][2]){ mx = max(mx, a[k]); } } } for (int t = i; t < j; t++){ for (int k = 1; k < j; k++){ if (f[k][1] > f[t][1] && f[k][2] < f[t][2]){ a[k] = max(a[k], f[k][1] + f[t][2]); } if (f[t][1] > f[k][1] && f[t][2] < f[k][2]){ a[t] = max(a[t], f[t][1] + f[k][2]); } } } if (mx != -1) out = max(out, f[i][0] + mx); i = j; } cout<<out<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...