제출 #853173

#제출 시각아이디문제언어결과실행 시간메모리
853173parsadox2Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector <int> find_subset(int l , int r , vector <int> t) { vector <pair<int ,int>> ar; int n = t.size(); for(int i = 0 ; i < n ; i++) ar.push_back({t[i] , i + 1}); sort(ar.begin() , ar.end()); vector <int> res; int num = 0 , sum = 0; for(int i = n - 1 ; i > -1 ; i--) { sum += ar[i].first; num++; if(sum >= l) break; } num--; if(sum < l) return res; int sum2 = 0; for(int i = 0 ; i <= num ; i++) sum2 += ar[i].first; if(sum2 > r) return res; int las = n - 1; while(sum2 < l) { sum2 += (ar[las].first - ar[num].first); num--; res.push_back(ar[las].second); las--; } for(int i = num ; i >= 0 ; i--) res.push_back(ar[i].second); reverse(res.begin() , res.end()); return res; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int l , r , n; cin >> l >> r >> n; vector <int> man; for(int i = 0 ; i < n ; i++) { int x; cin >> x; man.push_back(x); } vector <int> res = find_subset(l , r , man); for(auto u : res) cout << u << " "; cout << endl; return 0; }

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

/usr/bin/ld: /tmp/ccNc0zHo.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccERfvQn.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccNc0zHo.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status