제출 #865415

#제출 시각아이디문제언어결과실행 시간메모리
865415AlebnA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #define ll long long using namespace std; vector<int> a = {1, 2, 3, 9, 10, 11, 12, 12, 12, 12, 12}; void impossible() { cout << "Hi\n"; } void answer(vector<int> b) { for(int i = 0; i < b.size(); i++) cout << b[i] << "\n"; } ll skim(int i) { return a[i-1]; } void solve(int n, int k, ll A, int S) { vector<ll> a(n); bool ok = false; ll sum = 0; int mid = -1; for(int i = 0; i < n; i++) { a[i] = skim(i+1); if(a[i] >= A && mid == -1) mid = i; } for(int i = 0; i < k-1; i++) sum+=a[i]; mid = min(mid, k); for(int i = mid; i > k-2; i--) { if(sum+a[i] >= A && sum+a[i] <= 2*A) { vector<int> b(k); for(int j = 0; j < k-1; j++) b[j] = j+1; b[k-1] = i+1; answer(b); return; ok = true; } } if(!ok) impossible(); } int main() { solve(10, 4, 10, 10); }

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

books.cpp: In function 'void answer(std::vector<int>)':
books.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i < b.size(); i++) cout << b[i] << "\n";
      |                    ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccxvj26h.o: in function `answer(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0xa0): multiple definition of `answer(std::vector<int, std::allocator<int> >)'; /tmp/ccfwazei.o:books.cpp:(.text+0x20): first defined here
/usr/bin/ld: /tmp/ccxvj26h.o: in function `impossible()':
grader.cpp:(.text+0x160): multiple definition of `impossible()'; /tmp/ccfwazei.o:books.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccxvj26h.o: in function `skim(int)':
grader.cpp:(.text+0x1a0): multiple definition of `skim(int)'; /tmp/ccfwazei.o:books.cpp:(.text+0x90): first defined here
/usr/bin/ld: /tmp/ccxvj26h.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccfwazei.o:books.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status