CSES - NOI 2024 - Results
Submission details
Task:Thin Ice
Sender:Aino Aulanko
Submission time:2024-03-06 19:56:24 +0200
Language:C++11
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:30: error: expected ';' before 'if'
   20 |             c=max(t[d], t[e])
      |                              ^
      |                              ;
   21 |             if (c==t[d]){
      |             ~~                
input/code.cpp:24:13: error: 'else' without a previous 'if'
   24 |             else {
      |             ^~~~

Code

#include <bits/stdc++.h>

using namespace std;

int main(){
    long long int n, m, x, a=0, b, c, d, e, f;
    cin >> n >> m;
    long long int t[m]={0};
    for (long long int i=0; i<m; i++){
        cin >> x;
        t[i]=x;
    }
    for (long long int i=0; i<m; i++){
        b=t[i];
        c=t[i];
        f=1;
        d=i-1;
        e=i+1;
        while (c>1 && b>f){
            c=max(t[d], t[e])
            if (c==t[d]){
                d--;
            }
            else {
                e++;
            }
            b=min(c+f, b);
            f++;
        }
        a=max(a,b);
    }
    cout << a << "\n";
}