Submission #479864

#TimeUsernameProblemLanguageResultExecution timeMemory
479864ntabc05101Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "CAKES" const int mxN = 1000000; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); int n, k, l; cin >> n >> k >> l; vector<int> p; for (int i = 0, x; i < n; i++) { cin >> x; if (x != 0) { p.push_back(x); } } n = p.size(); //return 0; vector<long long> dp_cw(n), dp_ccw(n); for (int i = 0; i < n; i++) { if (i < k) { dp_cw[i] = min(l, 2 * p[i]); } else { dp_cw[i] = min(l, 2 * p[i]) + dp_cw[i - k]; } } for (int i = n - 1; i >= 0; i--) { if (i >= n - k) { dp_ccw[i] = min(l, 2 * (l - p[i])); } else { dp_ccw[i] = min(l, 2 * (l - p[i])) + dp_ccw[i + k]; } } long long res = min(dp_cw[n - 1], dp_ccw[0]); for (int i = 1; i < n; i++) { res = min(res, dp_cw[i - 1] + dp_ccw[i]); } cout << res << "\n"; return 0; }

Compilation message (stderr)

boxes.cpp: In function 'int main()':
boxes.cpp:24:13: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   24 |   n = p.size();
      |       ~~~~~~^~
boxes.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccxQ9jBc.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/cclmWkfd.o:boxes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccxQ9jBc.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status