Submission #1140302

#TimeUsernameProblemLanguageResultExecution timeMemory
1140302goatmar송신탑 (IOI22_towers)C++20
Compilation error
0 ms0 KiB
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

vector<int> H;
int N;

void init(int N, vector<int> H) {
    ::N = N;
    ::H = H;
}

int max_towers(int L, int R, int D) {
    int maxH = 0;
    for (int i = L; i <= R; ++i) {
        if (H[i] > maxH) {
            maxH = H[i];
        }
    }
    
    int count = 0;
    int last = -1;
    for (int i = L; i <= R; ++i) {
        if (H[i] <= maxH - D) {
            if (last == -1 || H[i] >= H[last]) {
                last = i;
                count++;
            }
        }
    }
    
    return count;
}

int main() {
    // Example usage
    init(7, {10, 20, 60, 40, 50, 30, 70});
    printf("%d\n", max_towers(1, 5, 10)); // Output: 3
    printf("%d\n", max_towers(2, 2, 100)); // Output: 1
    printf("%d\n", max_towers(0, 6, 17)); // Output: 2
    
    return 0;
}

Compilation message (stderr)

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