Submission details
Task:Traffic jam
Sender:aalto26am_049
Submission time:2026-08-31 17:40:36 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:9:18: error: expected ']' before ',' token
    9 |     int matrice[2,n];
      |                  ^
      |                  ]
input/code.cpp:9:20: error: expected initializer before ']' token
    9 |     int matrice[2,n];
      |                    ^
input/code.cpp:11:9: error: 'matrice' was not declared in this scope
   11 |         matrice[0][&i]=0;
      |         ^~~~~~~
input/code.cpp:18:22: error: 'matrice' was not declared in this scope
   18 |         while (num < matrice[0][&i]) {
      |                      ^~~~~~~
input/code.cpp:21:9: error: 'matrice' was not declared in this scope
   21 |         matrice[0][&compt]=num;
      |         ^~~~~~~
input/code.cpp:23:13: error: redeclaration of 'int num'
   23 |         int num = y ;
      |             ^~~
input/code.cpp:16:13: note: 'int num' previously declared here
   16 |         int num = x ;
      |             ^~~
input/code.cpp:24:13: error: redeclaration of 'int...

Code

#include <bits/stdc++.h> 
using namespace std;

int main() {
    int n;
    cin >> n;
    int x;
    int y;
    int matrice[2,n];
    for (int i=0; i<n ; i++) {
        matrice[0][&i]=0;
        matrice[1][&i]=0;
    }
    for (int i=0; i<2*n ; i++) {
        cin >> x >> y;
        int num = x ;
        int compt = 0;
        while (num < matrice[0][&i]) {
            compt++;
        }
        matrice[0][&compt]=num;

        int num = y ;
        int compt = 0;
        while (num < matrice[0][&i]) {
            compt++;
        }
        matrice[0][&compt]=num;
        matrice[1][&compt]=num;
    
    int max = 0;
    int maint = 0;
    for (int j=0;j<2*n;j++){
        if (matrice[1][&j]==0){
            maint++;
            if (maint >max){
                max=maint;
            }
        else {maint =0};
        }
    cout<<max;
    }
    return 0;
}