이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "meetings.h"
#define N 750009
#define LL 1000000009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz size
#define pb push_back
#define ll long long
using namespace std;
ll n, t[N], c[N], v[N];
void gur(int nd, int l, int r){
if(l==r){
t[nd]=v[l];
return;
}
int md=(l+r)/2;
gur(nd*2, l, md);
gur(nd*2+1, md+1, r);
t[nd]=max(t[nd*2], t[nd*2+1]);
}
ll tap(int nd, int l, int r, int x, int y){
if(l>y or r<x) return 0;
if(l>=x and r<=y)
return t[nd];
int md=(l+r)/2;
return max(tap(nd*2, l, md, x, y), tap(nd*2+1, md+1, r, x, y));
}
std::vector<ll> minimum_costs(std::vector<int>H, std::vector<int>L, std::vector<int>R){
n=H.sz();
for(int i=0; i<n; i++)
v[i]=H[i];
gur(1, 0, n-1);
vector<ll>e;
for(int i=0; i<L.sz(); i++){
int l=L[i], r=R[i];
for(int j=0; j<n; j++)
c[j]=1e18;
for(int j=l; j<=r; j++){
ll ans=0;
for(int h=l; h<=r; h++){
if(h<=j) ans+=tap(1, 0, n-1, h, j);
else ans+=tap(1, 0, n-1, j, h);
}
c[j]=ans;
}
ll mn=1e18;
for(int h=l; h<=r; h++)
mn=min(mn, c[h]);
e.pb(mn);
}
return e;
}
/*
int main(){
int M, q;
vector<int>H, A, B;
cin>>M>>q;
for(int i=0; i<M; i++){
int X;
cin>>X;
H.pb(X);
}
for(int i=0; i<q; i++){
int X, Y;
cin>>X>>Y;
A.pb(X), B.pb(Y);
}
vector<ll>e=minimum_costs(H, A, B);
for(auto i:e)
cout<<i<<' ';
}*/
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:47:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i=0; i<L.sz(); i++){
| ~^~~~~~~
# | 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... |