제출 #341034

#제출 시각아이디문제언어결과실행 시간메모리
34103412tqian선물상자 (IOI15_boxes)C++17
10 / 100
1 ms364 KiB
#include "boxes.h" #include <bits/stdc++.h> typedef long long ll; const ll INF = 2e9; long long delivery(int N, int K, int L, int p[]) { using namespace std; auto range = [&](int l, int r) -> int { ll res = INF; int mx = -INF; int mn = INF; for (int i = l; i <= r; i++) { mx = max(mx, p[i]); mn = min(mn, p[i]); } res = min(res, 2LL * mx); res = min(res, 2LL * (L - mn)); res = min(res, (ll) L); return res; }; ll ans = 1e18; auto solve = [&]() { ll res = 0; for (int l = 0; l < N; l += K) { int r = l+K-1; r = min(r, N-1); res += range(l, r); } ans = min(ans, res); }; solve(); int loc = 0; for (int i = 0; i < N; i++) { if (p[i] != 0) { loc = i; break; } } if (loc < N) reverse(p+loc, p+N); for (int i = loc; i < N; i++) p[i] = (L-p[i])%L; solve(); return ans; }

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

boxes.cpp: In lambda function:
boxes.cpp:18:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   18 |         return res;
      |                ^~~
#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...