이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
int delivery(int N, int K, int L, int positions[]){
//subtask 1 and 2
if(K==1){
ll ans=0;
for(int i=0;i<N;i++){
ans+=2*min(positions[i],L-positions[i]);
}
return ans;
}
sort(positions,positions+N);
ll ans=2LL*positions[N-1];
for(int i=0;i<N-1;i++){
mina(ans,2LL*positions[i]+2LL*(L-positions[i+1]));
}
mina(ans,2LL*(L-positions[0]));
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:35:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
35 | return ans;
| ^~~
boxes.cpp:43:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
43 | 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... |