Submission #831440

#TimeUsernameProblemLanguageResultExecution timeMemory
831440qin선물상자 (IOI15_boxes)C++14
Compilation error
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]; /*for(int i = 0; i < n; ++i) printf("%d ", d1[i]); printf("\n"); for(int i = 0; i < n; ++i) printf("%d ", d2[i]); printf("\n");*/ 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; }

Compilation message (stderr)

boxes.cpp: In constructor 'st::st(ll, int)':
boxes.cpp:7:16: warning: declaration of 'i' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |            ~~~~^
boxes.cpp:5:13: note: shadowed declaration is here
    5 |   ll w; int i;
      |             ^
boxes.cpp:7:9: warning: declaration of 'w' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |      ~~~^
boxes.cpp:5:6: note: shadowed declaration is here
    5 |   ll w; int i;
      |      ^
boxes.cpp: In constructor 'st::st(ll, int)':
boxes.cpp:7:16: warning: declaration of 'i' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |            ~~~~^
boxes.cpp:5:13: note: shadowed declaration is here
    5 |   ll w; int i;
      |             ^
boxes.cpp:7:9: warning: declaration of 'w' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |      ~~~^
boxes.cpp:5:6: note: shadowed declaration is here
    5 |   ll w; int i;
      |      ^
boxes.cpp: In constructor 'st::st(ll, int)':
boxes.cpp:7:16: warning: declaration of 'i' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |            ~~~~^
boxes.cpp:5:13: note: shadowed declaration is here
    5 |   ll w; int i;
      |             ^
boxes.cpp:7:9: warning: declaration of 'w' shadows a member of 'st' [-Wshadow]
    7 |   st(ll w, int i) : w(w), i(i) {}
      |      ~~~^
boxes.cpp:5:6: note: shadowed declaration is here
    5 |   ll w; int i;
      |      ^
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/ccvivjEz.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccodvldB.o:boxes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccvivjEz.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status