Submission #1002630

#TimeUsernameProblemLanguageResultExecution timeMemory
1002630LalicAutobahn (COI21_autobahn)C++17
0 / 100
1 ms464 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<double> cd; const int MAXN = 1e5+10; const int MOD = 1e9+7; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); ll arr[MAXN], spec[MAXN]; void solve(){ int n, k, x; cin >> n >> k >> x; int lim=-1; for(int i=0;i<n;i++){ int l, t, r; cin >> l >> t >> r; if(l+t<=r){ arr[l]++; arr[r+1]--; if(l+t<=r){ spec[l+t]++; spec[r+1]--; } } lim=max(lim, r); } for(int i=1;i<=lim;i++) arr[i]+=arr[i-1]; for(int i=1;i<=lim;i++) spec[i]+=spec[i-1]; ll ptr=1, curr=0, ans=0; for(int i=1;i<=lim;i++){ while(ptr<=lim && ptr-i<x){ if(arr[ptr]>=k) curr+=spec[ptr]; ptr++; } ans=max(ans, curr); if(arr[i]>=k) curr-=spec[i]; } cout << ans << "\n"; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tt=1; //~ cin >> tt; while(tt--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...