이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Bismillahirrahmanirrahim
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#define fori(A,B,C) for(int A=B; A<C; ++A)
#define ford(A,B,C) for(int A=B; A>=C; --A)
#define fi first
#define se second
#define pb push_back
#define pbp(A,B) pb({A,B})
#define pp(A,B) push({A,B})
using namespace std;
typedef long long ll;
const ll linf = 1e18;
vector < ll > l, r;
#include "boxes.h"
long long delivery(int N, int k, int L, int p[]) {
fori(i,0,N) {
if(p[i] <= L>>1)
l.pb(p[i]<<1);
else
r.pb((L - p[i])<<1);
}
reverse(r.begin(), r.end());
int lsz = l.size();
int rsz = r.size();
fori(i,k,lsz)
l[i] += l[i - k];
fori(i,k,rsz)
r[i] += r[i - k];
ll ans = (lsz ? l.back() : 0) + (rsz ? r.back() : 0);
for(int i = 0; i <= k; i++) {
ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ? r[r.size() - 1 - (k-i)] : 0) + L);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:18: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
int lsz = l.size();
~~~~~~^~
boxes.cpp:26:18: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
int rsz = r.size();
~~~~~~^~
boxes.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ? r[r.size() - 1 - (k-i)] : 0) + L);
~~^~~~~~~~~~
boxes.cpp:33:68: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ans = min(ans, (i < l.size() ? l[l.size() - 1 - i] : 0) + ((k-i) < r.size() ? r[r.size() - 1 - (k-i)] : 0) + L);
~~~~~~^~~~~~~~~~
# | 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... |