Submission details
Task:Establish equality
Sender:aalto26bm_031
Submission time:2026-09-07 17:46:23 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:21: error: expression cannot be used as a function
   20 |         while ((i<n)(b[i]<b[i+1])){
      |                ~~~~~^~~~~~~~~~~~~

Code

#include <bits/stdc++.h> 
using namespace std;
#define REP(i,a,b) for (int i = a; i < b; i++)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> b(n,0);
    REP(i,0,n){
        cin>>b[i];
    }
    sort(b.rbegin(),b.rend());
    while (b[0]>b[n-1]+1) {
        b[0]-=2;
        b[n-1]+=1;
        int i = 0;
        int retenue;
        while ((i<n)(b[i]<b[i+1])){
            retenue=b[i+1];
            b[i+1]= b[i];
            b[i]= retenue;
            i++;
        }
        i=n-1;
        while ((i>-1)&&(b[i]<b[i-1])){
            retenue=b[i-1];
            b[i-1]= b[i];
            b[i]= retenue;
            i--;
        }
    }
    cout<<b[n-1];
    return 0;
}