제출 #1041684

#제출 시각아이디문제언어결과실행 시간메모리
1041684simona1230선물상자 (IOI15_boxes)C++17
0 / 100
1 ms2396 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const long long maxn=1e7+5; long long dp1[maxn],dp2[maxn]; long long n,k,l; long long a[maxn]; long long l1,l2; long long ans=1e18; void solve() { for(long long i=0;i<n;i++) { if(a[i]<=n/2) { long long h=max(1LL*0,i-k); dp1[i]=dp1[h]+2*i; } } int mid=0; for(long long i=n-1;i>=0;i--) { if(a[i]>n/2) { long long h=i+k; if(h>=n)h=0; dp2[i]=dp2[h]+2*(n-i); } else {mid=i;break;} } for(int i=0;i<k;i++) { ans=min(ans,dp1[mid-i]+dp2[mid+k-i]); } } long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; for(long long i=0;i<n;i++) a[i]=p[i]; solve(); return 0; }

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

boxes.cpp: In function 'void solve()':
boxes.cpp:34:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   34 |         else {mid=i;break;}
      |                   ^
#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...