이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#ifndef EVAL
#include "grader.cpp"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
lol dis[5001][5001],mx[5001][5001];
vector<lol> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
int i,j,k,n = H.size(),Q = L.size();
vector<lol> C(Q);
set <pii> s;
for (i=0;i<n;++i){
for (j=0;j<n;++j){
dis[i][j]=1e15+7;
}
}
for (i=0;i<n;++i){
s.insert({i,i});
dis[i][i] = H[i];
mx[i][i] = H[i];
}
while (!s.empty()){
int l = s.begin()->fr;
int r = s.begin()->sc;
s.erase(s.begin());
if (l > 0){
mx[l-1][r] = max(mx[l-1][r],H[l-1]*1ll);
if (dis[l-1][r] > dis[l][r]+mx[l-1][r]){
dis[l-1][r] = dis[l][r]+mx[l-1][r];
s.insert({l-1,r});
}
}
if (r+1 < n){
mx[l][r+1] = max(mx[l][r],H[r+1]*1ll);
if (dis[l][r+1] > dis[l][r]+mx[l][r+1]){
dis[l][r+1] = dis[l][r]+mx[l][r+1];
s.insert({l,r+1});
}
}
}
for (j = 0; j < Q; ++j)
C[j] = dis[L[j]][R[j]];
return C;
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:31:13: warning: unused variable 'k' [-Wunused-variable]
31 | int i,j,k,n = H.size(),Q = L.size();
| ^
# | 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... |