Submission #587720

#TimeUsernameProblemLanguageResultExecution timeMemory
587720TekorTeam Contest (JOI22_team)C++17
0 / 100
49 ms5432 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(v) v.begin(),v.end() void boos() { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 2e5 + 100; const ll LLINF = (ll)1e18; map <int,int> was; int n,k,R; ll a[N],b[N],c[N],d[N],tekc; ll t[N * 4],t1[N * 4]; vector <int> q; void build(int v,int tl,int tr) { t1[v] = LLINF; if(tl == tr) { t[v] = LLINF; return; } int tm = (tl + tr) / 2; build(v + v,tl,tm); build(v + v + 1,tm + 1,tr); t[v] = LLINF; } void push(int v) { t[v + v] = min(t[v + v],t1[v]); t[v + v + 1] = min(t[v + v + 1],t1[v]); t1[v + v] = min(t1[v + v],t1[v]); t1[v + v + 1] = min(t1[v + v + 1],t1[v]); } void upd(int v,int tl,int tr,int l,int r,ll x) { if(tl > r || tr < l)return; if(tl >= l && tr <= r) { t1[v] = min(t1[v],x); t[v] = min(t[v],x); return; } push(v); int tm = (tl + tr) / 2; upd(v + v,tl,tm,l,r,x); upd(v + v + 1,tm + 1,tr,l,r,x); t[v] = min(t[v + v],t[v + v + 1]); } ll get(int v,int tl,int tr,int l,int r) { if(tl > r || tr < l)return LLINF; if(tl >= l && tr <= r) { return t[v]; } push(v); int tm = (tl + tr) / 2; return min(get(v + v,tl,tm,l,r),get(v + v + 1,tm + 1,tr,l,r)); } bool cmp(int x,int y) { return a[x] < a[y]; } void add(int pos) { int p = was[b[pos]]; upd(1,1,k,1,p,c[pos]); int lr = max(R + 1,p + 1); while(lr <= k && get(1,1,k,lr,k) < max(c[pos],tekc)) { R = lr; tekc = max(tekc,c[pos]); lr++; } lr = R + 1; while(lr <= k && get(1,1,k,lr,k) < tekc) { R = lr; lr++; } } void solve() { cin >> n; vector <int> g; ll mx = 0; for(int i = 1;i <= n;i++) { cin >> a[i] >> b[i] >> c[i]; q.pb(b[i]); g.pb(i); } sort(all(g),cmp); sort(all(q)); was[q[0]] = ++k; d[k] = q[0]; for(int i = 1;i < q.size();i++) { if(q[i] != q[i - 1])was[q[i]] = ++k; d[k] = q[i]; } build(1,1,k); ll ans = -1; R = 0; tekc = -LLINF; for(int i = 1;i < g.size();i++) { if(a[g[i - 1]] != a[g[i]]) { int pos = i - 1; while(pos >= 0 && a[g[pos]] == a[g[i - 1]]) { add(g[pos]); //cout << g[pos] << " dob" << endl; pos--; } } if(tekc > c[g[i]] && d[R] > b[g[i]])ans = max(ans,a[g[i]] + tekc + d[R]); //cout << ans << " -- " << a[g[i]] << " " << d[R] << " " << tekc << " " << R << endl; } cout << ans; } int main() { boos(); solve(); }

Compilation message (stderr)

team.cpp: In function 'void solve()':
team.cpp:89:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |  for(int i = 1;i < q.size();i++) {
      |                ~~^~~~~~~~~~
team.cpp:97:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |  for(int i = 1;i < g.size();i++) {
      |                ~~^~~~~~~~~~
team.cpp:79:5: warning: unused variable 'mx' [-Wunused-variable]
   79 |  ll mx = 0;
      |     ^~
#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...