Submission #1042498

#TimeUsernameProblemLanguageResultExecution timeMemory
1042498kimnhatdev1106휴가 (IOI14_holiday)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5 + 5;
int n, s, d, a[N], ans, mp[N];

void ql(int pos, int sum, int d){
    if(d == 0){
        ans = max(ans, sum);
        return;
    }

    if(mp[pos] == 0){
        mp[pos] = 1;
        ql(pos, sum + a[pos], d - 1);
        mp[pos] = 0;
    }
    if(pos > 0){
        ql(pos - 1, sum, d - 1);
    }
    
    if(pos + 1 < n){
        ql(pos + 1, sum, d - 1);
    }
}

main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s >> d;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ql(s, 0, d);
    cout << ans;
}

Compilation message (stderr)

holiday.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
/usr/bin/ld: /tmp/ccWYOk9v.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWBeMpy.o:holiday.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccWYOk9v.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status