제출 #401783

#제출 시각아이디문제언어결과실행 시간메모리
401783iulia13선물상자 (IOI15_boxes)C++14
0 / 100
1 ms332 KiB
#include "boxes.h" #include <iostream> #include <algorithm> using namespace std; #define ll long long const int N = 1e7; ll dp1[N * 2]; ll dp2[N * 2]; ll delivery(int n, int k, int l, int p[]) { sort(p, p + n); ll ans = N * N; int i; for (i = 0; i < n; i++) { if (i < k) dp1[i] = 1ll * p[i] * 2; else dp1[i] = 1ll * p[i] * 2 + dp1[i - k]; } for (i = n - 1; 0 <= i; i--) { if (n - i <= k) dp2[i] = 1ll * (l - p[i]) * 2; else dp2[i] = 1ll * (l - p[i]) * 2 + dp2[i + k]; } for (i = 0; i < n; i++) ans = min(dp1[i] + dp2[i + k + 1] + l, ans); return ans; }/* int n, k, l; int pp[N]; int main() { cin >> n >> k >> l; for (int i = 0; i < n; i++) cin >> pp[i]; cout << delivery(n, k, l, pp); return 0; }*/

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:16: warning: integer overflow in expression of type 'int' results in '276447232' [-Woverflow]
   12 |     ll ans = N * N;
      |              ~~^~~
#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...