제출 #831443

#제출 시각아이디문제언어결과실행 시간메모리
831443qin선물상자 (IOI15_boxes)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct st{ ll w; int i; st(){} st(ll W, int I) : w(W), i(I) {} }; int main(){ int n, k, l; scanf("%d%d%d", &n, &k, &l); vector<int> t(n), d1(n+1), d2(n+1); for(int i = 0; i < n; ++i) scanf("%d", &t[i]); d1[0] = t[0], d2[n] = l-t[n-1]; for(int i = 1; i < n; ++i) d1[i] = t[i]-t[i-1]; for(int i = n-1; i; --i) d2[i] = d1[i] + d2[i+1]; for(int i = 1; i < n; ++i) d1[i] += d1[i-1]; for(int i = 0; i < n; ++i) d2[i] = d2[i+1]; vector<ll> dp1(n), dp2(n); deque<st> dq; dq.emplace_back(0, -1); for(int i = 0; i < n; ++i){ if(!dq.empty() && i-dq.front().i > k) dq.pop_front(); dp1[i] = dq.front().w+ll(d1[i]<<1); while(!dq.empty() && dq.back().w >= dp1[i]) dq.pop_back(); dq.emplace_back(dp1[i], i); } while(!dq.empty()) dq.pop_back(); dq.emplace_back(0, n); for(int i = n-1; ~i; --i){ if(!dq.empty() && dq.front().i-i > k) dq.pop_front(); dp2[i] = dq.front().w+ll(d2[i]<<1); while(!dq.empty() && dq.back().w >= dp2[i]) dq.pop_back(); dq.emplace_back(dp2[i], i); } ll wynik = min(dp1[n-1], dp2[0]); for(int i = 0; i < n-1; ++i) wynik = min(wynik, dp1[i]+dp2[i+1]); printf("%lld\n", wynik); return 0; }

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

boxes.cpp: In function 'int main()':
boxes.cpp:10:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   int n, k, l; scanf("%d%d%d", &n, &k, &l);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:12:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   for(int i = 0; i < n; ++i) scanf("%d", &t[i]);
      |                              ~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccmdzl1Z.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccTpNEr0.o:boxes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccmdzl1Z.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status