제출 #420348

#제출 시각아이디문제언어결과실행 시간메모리
420348Azimjon선물상자 (IOI15_boxes)C++17
35 / 100
1 ms304 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int INF = 2e9; long long delivery(int n, int k, int L, int p[]) { int x = 0; for (x = 0; x < n; x++) if (p[x]) break; n -= x; for (int i = 0; i < n; i++) p[i] = p[i + x]; long long ans = 0; double ur = L / 2; int m; for (m = 0; m < n; m++) if (p[m] > ur) break; int l = m - 1; int r = m; cerr << l << " " << r << endl; while (1) { if (l - k + 1 >= 0) { ans += 2 * p[l]; l -= k; } else break; } while (1) { if (r + k - 1 < n) { ans += 2 * (L - p[r]); r += k; } else break; } long long o = 0; if (l >= 0) o += 2 * p[l]; if (r < n) o += 2 * (L - p[r]); if (p[l] == 0) l = -1; int q = 0; if (l >= 0) q += l + 1; if (r < n) q += n - r; cerr << l << "--" << r << endl; if (q <= k) { o = min(o, (long long)L); } else { int w = q - k; int v = k; while (v--) { if (l >= 0 && r < n && p[l] < L - p[r]) { r++; } else if (l >= 0 && r < n) { l--; } else if (l >= 0) { l--; } else { r++; } } long long uy = 0; if (l >= 0) uy += 2 * p[l]; if (r < n) uy += 2 * (L - p[r]); o = min(o, uy + L); } cerr << o << endl; return ans + o; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:57:7: warning: unused variable 'w' [-Wunused-variable]
   57 |   int w = q - k;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...