제출 #989331

#제출 시각아이디문제언어결과실행 시간메모리
989331normankr07선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#define taskname "" #include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #ifndef LOCAL #define cerr \ if (0) \ cerr #endif const bool multitest = 0; const int MAXN = 1e7 + 5; int pos[MAXN]; long long delivery(int N, int K, int L, int p[]) { vector<ll> lt(N + 3), rt(N + 3); for (int i = 1; i <= N; i++) { if (i - K >= 0) { lt[i] = lt[i - K] + p[i - 1] * 2; rt[i] = rt[i - K] + ((L - p[N - i]) * 2); } else { lt[i] = p[i - 1] * 2; rt[i] = ((L - p[N - i]) * 2); } } // for (int i = 1; i <= N; i++) // cout << lt[i] << ' '; // cout << endl; // for (int i = 1; i <= N; i++) // cout << rt[i] << ' '; // cout << endl; ll ans = 1e18; for (int i = 1; i <= N; i++) { ans = min(ans, lt[i] + rt[N - i]); } for (int i = K - 1; i < N; i++) { ans = min(ans, lt[i - K + 1] + rt[N - i - 1] + L); } return ans; } void solve() { int n, k, l; cin >> n >> k >> l; for (int i = 0; i < n; i++) { cin >> pos[i]; } cout << delivery(n, k, l, pos); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen(taskname ".inp", "r")) { freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } int tc = 1; if (multitest) cin >> tc; while (tc--) { solve(); cout << '\n'; } }

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

boxes.cpp: In function 'int32_t main()':
boxes.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(taskname ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(taskname ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccWnYse8.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccchRKH6.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status