Submission #1045472

#TimeUsernameProblemLanguageResultExecution timeMemory
1045472pccThe short shank; Redemption (BOI21_prison)C++17
0 / 100
34 ms4568 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second const int mxn = 2e6+10; int N,D,T; vector<int> seq[3]; vector<pii> v; int arr[mxn]; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>D>>T; int ans = N; for(int i = 1;i<=N;i++){ cin>>arr[i]; if(arr[i]<=T)continue; if(v.empty()||v.back().sc != i-1)v.push_back(pii(i,i)); else v.back().sc++; } for(auto &[s,e]:v){ int c = 1; if(s == 1)c--; seq[c].push_back(e-s+1); } for(auto &i:seq)sort(i.rbegin(),i.rend()); for(int i = 0;i<D&&i<seq[1].size();i++)ans -= seq[1][i]; for(auto &i:seq[0])ans -= i; cout<<ans<<'\n'; return 0; }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i = 0;i<D&&i<seq[1].size();i++)ans -= seq[1][i];
      |                     ~^~~~~~~~~~~~~~
#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...