Submission #1216615

#TimeUsernameProblemLanguageResultExecution timeMemory
1216615maomaoThe short shank; Redemption (BOI21_prison)C++20
Compilation error
0 ms0 KiB
//https://oj.uz/problem/view/BOI21_prison #include <iostream> #include <queue> #include <algorithm> using namespace std; #define pii pair<int,int> #define f first #define s second int main() { int n,d,t; cin >> n >> d >> t; int p[n+1]; int prev = n; FOR(i,1,n+1) cin >> p[i]; priority_queue<pii,vector<pii>> pq; //find pos to put mattress for(int i=n;i>1;i--) { if(p[i]>t && t>p[i-1]) { pq.push({max(prev-i+1,t-p[i-1]),i-1}); prev=i-1; } } //take D topmost int pos[d]; for(int i=0;i<d;i++) { pos[i] = pq.top().s; pq.pop(); } sort(pos,pos+d); for(int i=0;i<d-1;i++) { int l=pos[i]+1, r=pos[i+1]-1; for(int j=l;j<r;j++){ if(p[j]<t && t<p[j+1]) p[j+1] = p[j]+1; } } int ans = 0; for(int i=1;i<=n;i++) if(p[i]<=t) ans++; cout << ans; return 0; }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:12:9: error: 'i' was not declared in this scope
   12 |     FOR(i,1,n+1) cin >> p[i];
      |         ^
prison.cpp:12:5: error: 'FOR' was not declared in this scope
   12 |     FOR(i,1,n+1) cin >> p[i];
      |     ^~~