제출 #1040724

#제출 시각아이디문제언어결과실행 시간메모리
1040724idas선물상자 (IOI15_boxes)C++11
100 / 100
388 ms293760 KiB
#include "boxes.h" #include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) using namespace std; typedef long long ll; const ll LINF=1e18; const int MxN=1e7+10; ll n, k, l, a[MxN], b[MxN]; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; int in=0; while(in<n && p[in]==0) in++; FOR(i, in, n) p[i-in]=p[i]; n-=in; FOR(i, 0, n) { if(i-k>=0) a[i]=a[i-k]; a[i]+=p[i]; a[i]+=min(1LL*p[i], l-p[i]); } for(int i=n-1; i>=0; i--){ if(i+k<=n-1) b[i]=b[i+k]; b[i]+=l-p[i]; b[i]+=min(1LL*p[i], l-p[i]); } ll ans=min(a[n-1], b[0]); FOR(i, 0, n-1) ans=min(ans, a[i]+b[i+1]); return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:27:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   27 |     for(int i=n-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...