Submission #420383

#TimeUsernameProblemLanguageResultExecution timeMemory
420383JvThunderAutobahn (COI21_autobahn)C++14
50 / 100
175 ms5728 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fir first #define sec second typedef long long ll; using namespace std; int n,k,x; int add[1005] = {0}; vector<pair<int,pair<int,int>>> v; void solve() { cin >> n >> k >> x; for(int i=0;i<n;i++) { int l,t,r; cin >> l >> t >> r; v.pb({l,{t,r}}); } for(int i=1;i<=1000;i++) { int extracnt = 0; int cnt = 0; for(int j=0;j<n;j++) { if(v[j].fir<=i && i<=v[j].sec.sec) { cnt++; if(v[j].fir+v[j].sec.fir<=i) extracnt++; } } if(cnt>=k) add[i] = extracnt; } int sum = 0; int mxsum = 0; for(int i=1;i<=x;i++) sum += add[i], mxsum = max(mxsum,sum); for(int i=x+1;i<=1000;i++) sum -= add[i-x], sum += add[i], mxsum = max(mxsum,sum);; cout << mxsum << endl; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tc=1; //cin>>tc; for(int i=1;i<=tc;i++) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...