이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <chrono>
#define pi 3.141592653589793238
#define ll long long
#define ld long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 1000000007ll
#define INF 1000000000000000000
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast \
ios_base::sync_with_stdio (false); \
cin.tie (NULL); \
cout.tie (NULL)
using namespace std;
long long delivery(int N, int K, int L, int P[]) {
ll n=N, k=K, l=L, p[n];
rep(i,0,n-1)
p[i]=P[i];
ll dp[n];
ll rdp[n];
for(int i=0;i<n;i++)
{
dp[i]=(i-k>=0?dp[i-k]:0)+min(l,2*p[i]);
}
for(int i=n-1;i>=0;--i)
{
rdp[i]=(i+k<n?rdp[i+k]:0)+min(l,2*(l-p[i]));
}
ll ret=min(dp[n-1],rdp[0]);
rep(i,0,n-2)
ret=min(ret,dp[i]+rdp[i+1]);
return ret;
}
// signed main()
// {
// int n=3;
// int k=2;
// int l=8;
// int p[]={1,2,5};
// cout<<delivery(n,k,l,p);
// }
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:54:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
54 | 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... |