Submission #657798

# Submission time Handle Problem Language Result Execution time Memory
657798 2022-11-11T07:36:42 Z coding_snorlax Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> All;
void init(int N,vector<int> H){
    for(int i=0;i<N;i++){
        All.push_back(H[i]);
    }
}
int recrution(int L,int R,int D){
    int Now_max=-2000000000,Max_place=-1;
    for(int i=L;i<=R;i++){
        if(All[i]>Now_max ){
            Now_max=max(Now_max,All[i]);
            Max_place=i;
        }
    }
    int flag1=0,flag2=0;
    for(int i=L;i<Max_place;i++){
        if(All[i]+D<=Now_max){
            flag1=1;
        }
    }
    for(int i=Max_place+1;i<=R;i++){
        if(All[i]+D<=Now_max){
            flag2=1;
        }
    }
    if(flag1 && flag2) return recrution(L,Max_place-1,D)+recrution(Max_place+1,R,D);
    else return 1;
}
int max_towers(int L,int R,int D){
    return recrution(L,R,D);
}
int main(){
    vector<int> W={10,20,60,40,50,30,70};
    init(7,W);
    cout<<max_towers(1,5,10)<<endl;
    //cout<<max_towers(0,4,6)<<endl;
    //cout<<max_towers(1,2,3)<<endl;
    //cout<<max_towers(0,5,7)<<endl;
    //cout<<max_towers(1,6,3)<<endl;
}

Compilation message

/usr/bin/ld: /tmp/ccLvZTfz.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccfCEueC.o:towers.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status