CSES - Aalto Competitive Programming 2024 - wk3 - Wed - Results
Submission details
Task:Sorting coins
Sender:aalto2024c_009
Submission time:2024-09-18 17:50:09 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:28:14: error: conflicting declaration 'bool a'
   28 |         bool a=false;
      |              ^
input/code.cpp:27:13: note: previous declaration as 'int a'
   27 |         int a = r_coins[i];
      |             ^

Code

#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    
    int n, m; // coins, holes
    cin >> n >> m;
 
    vector<int> r_coins;
    vector<int> r_holes;
    
 
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        r_coins.push_back(a);
    }
    
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        r_holes.push_back(b);
    }

    for(int i=0; i<n; i++ ){
        int a = r_coins[i];
        bool a=false;
        for(int l=0; l<m; l++){
            if(r_holes[l]>=r_coins[i]){
                cout<<l<<" ";
                a=true;
                break;
            }
        }
        if(a==false){
            cout << m+1 <<" ";
        }

    }
 
 
}