이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k) for(int i = j ; i < k ; ++i)
#define RREP(i,j,k) for(int i = j ; i >=k ; --i)
#define A first
#define B second
#define mp make_pair
#define pb emplace_back
#define PII pair<int , int>
#define MEM(i,j) memset(i , j , sizeof i)
#define ALL(i) i.begin() , i.end()
#define DBGG(i,j) cout << i << " " << j << endl
#define DB4(i,j,k,l) cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 10000090
#define INF 0x3f3f3f3f
long long fr[MAX] , ba[MAX];
int delivery(int n , int k , int l , int *x){
if(n == 1) return 0;
else {
sort(x , x + n);
// REP(i , 0 , n) cout << x[i] << " "; cout << endl;
REP(i , 0 , n)
fr[i] = (i - k >= 0 ? fr[i - k] : 0) + (min(l - x[i] , x[i]) + x[i]);
RREP(i , n - 1 , 0)
ba[i] = (i + k < n ? ba[i + k] : 0) + (min(l - x[i] , x[i]) + l - x[i]);
// REP(i , 0 , n) cout << fr[i] << " "; cout << endl;
// REP(i , 0 , n) cout << ba[i] << " "; cout << endl;
long long ans = min(fr[n - 1] , ba[0]);
REP(i , 0 , n - 1) ans = min(ans , fr[i] + ba[i + 1]);
return ans;
}
}
// int n = 3 , k = 2 , l = 8 , x[MAX] = {1 , 2 , 5};
// int32_t main(){
// IOS;
// // cin >> n >> k >> l;
// // REP(i , 0 , n) cin >> x[i];
// cout << delivery(n , k , l , x) << endl;
// return 0;
// }
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:41:10: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return ans;
^~~
# | 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... |