Submission #420470

#TimeUsernameProblemLanguageResultExecution timeMemory
420470JvThunderAutobahn (COI21_autobahn)C++17
50 / 100
137 ms2996 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<v.size();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; }

Compilation message (stderr)

autobahn.cpp: In function 'void solve()':
autobahn.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...