이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp male_pair
#define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)
#define fora(i, a, b) for(int i = int(a); i >= int(b); -- i)
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<ll> vl;
long long delivery(int N, int K, int L, int p[]) {
vl menores;
vl mayores;
menores.pb(0LL);
forn(i, 0, N - 1){
if(!p[i]){
continue;
}
if(p[i] <= L / 2){
menores.pb((ll) p[i] * 2LL);
}
else{
mayores.pb(((ll) L - (ll) p[i]) * 2LL);
}
}
mayores.pb(0LL);
int lon1 = menores.size(), lon2 = mayores.size();
forn(i, K + 1, lon1 - 1){
menores[i] += menores[i - K];
}
reverse(mayores.begin(), mayores.end());
forn(i, K + 1, lon2){
mayores[i] += mayores[i - K];
}
if(lon1 == 1 && lon2 == 1){
return 0LL;
}
if(lon1 == 1){
return mayores[lon2 - 1];
}
if(lon2 == 1){
return menores[lon1 - 1];
}
ll res = mayores[lon2 - 1] + menores[lon1 - 1];
forn(i, 1, K - 1){
res = min(res, menores[max(lon1 - i - 1, 0)] + mayores[max(lon2 - (K - i) - 1, 0)] + L);
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:32:28: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
32 | int lon1 = menores.size(), lon2 = mayores.size();
| ~~~~~~~~~~~~^~
boxes.cpp:32:51: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
32 | int lon1 = menores.size(), lon2 = mayores.size();
| ~~~~~~~~~~~~^~
# | 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... |