이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |