제출 #1140306

#제출 시각아이디문제언어결과실행 시간메모리
1140306goatmar송신탑 (IOI22_towers)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> alturas; void init(int N, const vector<int>& H) { alturas = H; } int max_towers(int L, int R, int D) { vector<int> subAlturas(alturas.begin() + L, alturas.begin() + R + 1); int tamSub = subAlturas.size(); int maxArrendar = 1; for (int i = 0; i < tamSub; ++i) { for (int j = i + 1; j < tamSub; ++j) { for (int k = i + 1; k < j; ++k) { if (subAlturas[i] <= subAlturas[k] - D && subAlturas[j] <= subAlturas[k] - D) { int cuentaArrendar = j - i + 1; maxArrendar = max(maxArrendar, cuentaArrendar); } } } } return maxArrendar; } int main() { init(7, {10, 20, 60, 40, 50, 30, 70}); cout << max_towers(1, 5, 10) << endl; // Salida: 3 cout << max_towers(2, 2, 100) << endl; // Salida: 1 cout << max_towers(0, 6, 17) << endl; // Salida: 2 return 0; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccZBcuk7.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclCtRsK.o:towers.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccZBcuk7.o: in function `main':
stub.cpp:(.text.startup+0x15f): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status