제출 #30545

#제출 시각아이디문제언어결과실행 시간메모리
30545kavun선물상자 (IOI15_boxes)C++14
10 / 100
2 ms400 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; long long n,l,k,ans = 1e18, cw[10000010], ccw[10000010], lmid = -1, rmid = -1; long long delivery(int N, int K, int L, int p[]) { n = N; k = K; for(int i = 0; i < n; i++) { if(p[i] <= L/2) lmid = i; if(p[i] > L/2) { rmid = i; break; } } for(int i = 0; i < k; i++) cw[i] = 2*p[i]; for(int i = k; i < n; i++) cw[i] = cw[i-k] + 2*p[i]; for(int i = n-1; i >= n-k; i--) ccw[i] = 2*(L-p[i]); for(int i = n-k-1; i >= 0; i--) ccw[i] = ccw[i+k] + 2*(L-p[i]); for(int i = 0; i < n; i++) { if(i + k >= n-1) ans = min(ans,cw[i] + L); else if(p[i+k] > L/2) ans = min(ans,cw[i] + L + 2*ccw[i+k+1]); } long long ans2 = 0; if(lmid > -1) ans2 += cw[lmid]; if(rmid > -1) ans2 += ccw[rmid]; ans = min(ans,ans2); if(n == K && lmid > -1 && rmid > -1) return L; return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:24:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   for(int i = k; i < n; i++)
               ^
boxes.cpp:26:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   for(int i = n-1; i >= n-k; i--)
               ~^~
boxes.cpp:28:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   for(int i = n-k-1; i >= 0; i--)
               ~~~^~
#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...