제출 #204143

#제출 시각아이디문제언어결과실행 시간메모리
204143awlintqaa선물상자 (IOI15_boxes)C++14
10 / 100
6 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll ; #include "boxes.h" ll n , sz ; ll num =0 ,ans = 0; ll a[100009]; ll val[100009]; ll solve1(ll x){ return x ; } ll solve2 ( ll x ){ return sz - x ; } ll calc1(ll crnt , ll z ){ for(int i=0 ;i < n;i ++ ){ crnt-=val[i]; if(val[i])val[i] -= z; if ( crnt == 0 ){ ll X = solve1(a[i]); ll xxx = min (solve1(a[i]) , solve2(a[i]) ); return X + xxx; } } return 0 ; } ll calc2(ll crnt , ll z ){ for(int i = n-1 ;i >=0 ; i-- ) { crnt -= val[i]; if (val[i])val[i] -= z; if ( crnt == 0 ){ ll X = solve2(a[i]); ll xxx = min ( solve1(a[i]) , solve2(a[i]) ); return X + xxx; } } return 0 ; } long long delivery(int N, int K, int L, int p[]) { n = N , sz = L ; num = n ; for ( int i =0 ;i < n ;i ++ ){ a[i]=p[i]; val[i]=1; } while( num > 0 ){ ll val1=calc1( min ( num , (ll)K) , 0 ) ; ll val2=calc2( min ( num , (ll)K) , 0 ) ; if ( val1 <= val2 ) { ans += val1; calc1 ( min ( num , (ll)K) , 1 ) ; } else { ans += val2; calc2 ( min ( num , (ll)K) , 1 ) ; } num -= min ( num , (ll)K ) ; } return ans; }

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

boxes.cpp: In function 'll calc2(ll, ll)':
boxes.cpp:28:22: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         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...