Submission #894441

#TimeUsernameProblemLanguageResultExecution timeMemory
894441vjudge1The short shank; Redemption (BOI21_prison)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,d,T; cin>>n>>d>>T; vector<int> v(n); for(int& i : v) cin>>i; // MATRESSES ONLY CAN BE PLACED between a good and a bad --> covers a segment of just bad, so i place a matress in the ones that "recover" more spits vector<int> newv(n,0); newv[0] = v[0]; set<int> ; for(int i = 0; i<n; i++){ if(v[i] <= T) good.insert(i); } vector<int> canplace; for(int i = 1; i<n; i++){ newv[i] = min(newv[i-1]+1,v[i]); if(v[i] > T && v[i-1] < T){ // TAKE ACTUAL BEST VALUE int len = *good.lower_bound(i) - i; len = min(len, T-newv[i-1]); canplace.push_back(len); } } sort(canplace.begin(),canplace.end()); int sz = canplace.size(); for(int i = 0; i<min(sz,d); i++){ canplace.pop_back(); } // will revel int ans = 0; for(int i : canplace) ans+=i; ans+=good.size(); cout<<ans<<endl; }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:12:2: error: declaration does not declare anything [-fpermissive]
   12 |  set<int>  ;
      |  ^~~~~~~~
prison.cpp:14:17: error: 'good' was not declared in this scope
   14 |   if(v[i] <= T) good.insert(i);
      |                 ^~~~
prison.cpp:21:15: error: 'good' was not declared in this scope
   21 |    int len = *good.lower_bound(i) - i;
      |               ^~~~
prison.cpp:34:7: error: 'good' was not declared in this scope
   34 |  ans+=good.size();
      |       ^~~~