Submission #1264681

#TimeUsernameProblemLanguageResultExecution timeMemory
1264681InvMODBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define pi pair<int,int> #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) template<class T> using upq = priority_queue<T, vector<T>, greater<T>>; template<class T> int lwrbound(const vector<T>& a, const T& b, const int s = 0){return int(lower_bound(s + all(a), b) - a.begin());} template<class T> int uprbound(const vector<T>& a, const T& b, const int s = 0){return int(upper_bound(s + all(a), b) - a.begin());} #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define ROF(i, a, b) for(int i = (a); i >= (b); i--) #define sumof(x) accumulate(all(x), 0ll) #define dbg(x) "[" << #x " = " << (x) << "]" #define el "\n" #define name "InvMOD" using ll = long long; using ld = long double; template<class T> bool ckmx(T& a, const T b){return (a < b ? a = b, true : false);} template<class T> bool ckmn(T& a, const T b){return (a > b ? a = b, true : false);} ll delivery(int n, int k, int L, vi a){ vector<ll> pos(n + 1); FOR(i, 1, n){ pos[i] = a[i - 1]; } vector<ll> pre(n + 1), suf(n + 2); FOR(i, 1, n){ pre[i] = pre[max(0, i - k)] + pos[i] * 2; } ROF(i, n, 1){ suf[i] = suf[min(n + 1, i + k)] + (L - pos[i]) * 2; } ll ans = 1e18; FOR(i, 0, n){ ckmn(ans, pre[i] + suf[i + 1]); if(i > 0 && i + k <= n){ ckmn(ans, pre[i - 1] + suf[i + k] + L); } } return ans; } #ifdef name int32_t main() { freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); int n, k, L; cin >> n >> k >> L; vi pos(n); FOR(i, 0, n - 1) cin >> pos[i]; cout << delivery(n, k, L, pos) << el; return 0; } #endif // name

Compilation message (stderr)

boxes.cpp: In function 'int32_t main()':
boxes.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(name".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccKKueZU.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccBKT4u6.o:boxes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKKueZU.o: in function `main':
grader.c:(.text.startup+0x1ec): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status