제출 #1201627

#제출 시각아이디문제언어결과실행 시간메모리
1201627Joon_Yorigami선물상자 (IOI15_boxes)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; long long delivery(int N, int K, int L, int v[]){ //N is the number of teams that need their gifts //K is the carrying capacity //L is the number of nodes (ex. L = 8 gives us: 0,1,2,3,4,5,6,7) //v[] is an array vector<long long> team_pos; team_pos.push_back(0); for(int i = 0; i<N; i++){ team_pos.push_back(v[i]); } vector<long long> cw(N+K+5, 0); vector<long long> ccw(N+5, 0); cw[0] = 0; ccw[0] = 0; sort(team_pos.begin(), team_pos.end()); //----- ACCOUNT FOR DEFAULT FIRST //cw[i] = minimum total distance to DELIVER FIRST i GIFTS via CW //ccw[i] = minimum total distance to DELIVER FIRST i GITS via CCW for (int i = 1; i <= N; i++){ long long d_cw = 2*team_pos[i]; long long d_ccw = 2*(L - team_pos[N - i + 1]); cw[i] = min(d_cw, (long long)L); ccw[i] = min(d_ccw, (long long)L); } //------ ACCOUNT FOR CAPACITY //cout << "ACCOUNT FOR CAPACITY\n"; for (int i = K+1; i <= N; i++){ //cout << i << " " << i-K << "\n"; cw[i] += cw[i-K]; } for (int i = 0; i <= N-K; i++){ //cout << N-i << " " << N-(i+K) << "\n"; ccw[N-i] += ccw[N-(i+K)]; } //print /*for(int i =0 ; i<cw.size(); i++){ cout << "cw[" << i << "] = " << cw[i] << "\n"; } cout << "\n"; for(int i =0 ; i<cw.size(); i++){ cout << "ccw[" << i << "] = " << ccw[i] << "\n"; }*/ //cout << "\n"; long long no_full = 1e18; long long yes_full = 1e18; for(int i = 0; i<=N; i++){ no_full = min(no_full, cw[i] + ccw[N-i]); //cout << i << " " << no_full << "\n"; } //cout << "\n"; for(int i = 0 ; i+K <= N; i++){ yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]); //cout << i << " " << yes_full << "\n"; } //cout << no_full << " " << yes_full << "\n"; //cout << min(no_full, yes_full) << "\n"; return min(no_full, yes_full); } int main(){ int n; int k; int l; cin >> n >> k >> l; int v[n]; for(int i = 0; i<n; i++){ int x; cin >> x; v[i] = x; } cout << delivery(n,k,l,v) << endl; }

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

/usr/bin/ld: /tmp/ccwpKwka.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJSrTqP.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status