이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/// Black lives matter
#include <bits/stdc++.h>
#include "boxes.h"
/// 500 485 462 A4
using namespace std;
typedef long long int ll;
typedef complex<double> point;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
//#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
const int MAXN=1e5+10;
ll dp[MAXN],pd[MAXN];
ll t[MAXN];
long long delivery(int32_t n, int32_t k, int32_t l, int32_t p[]) {
for (int i=0;i<n;i++) dp[i]=(ll)1e15,pd[i]=(ll)1e15;
for (int i=0;i<n;i++) t[p[i]]++;
ll cnt=0;
dp[0]=0,pd[0]=0;
for (int i=0;i<l;i++){
for (int j=0;j<t[i];j++){
cnt++;
dp[cnt]=2*i+dp[max((ll)0,cnt-k)];
}
}
cnt=0;
for (int i=-1;i>-l;i--){
ll z=i+l;
for (int j=0;j<t[z];j++){
cnt++;
pd[cnt]=2*(-i)+pd[max((ll)0,cnt-k)];
}
}
ll ans=(ll)1e15;
for (int i=0;i<=n;i++){
ans=min(ans,dp[i]+pd[n-i]);
}
return ans;
}
/*
int32_t p[MAXN];
int32_t main(){
sync;
ll n,k,l;
cin >> n >> k >> l;
for (int i=0;i<n;i++){
cin >> p[i];
}
cout << delivery(n,k,l,p);
}
*/
/*
3 2 8
1 2 5
*/
# | 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... |