이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "meetings.h"
#define N 800009
#define LL 1000000009
#define ll long long
#define pii pair <ll, ll>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
using namespace std;
ll n, t[N], c[N];
pii a[N];
vector<pii>e;
vector<ll>ans;
std::vector<ll> minimum_costs(std::vector<int>v, std::vector<int>L, std::vector<int>R){
n=v.sz();
for(int i=0; i<L.sz(); i++){
int l=L[i], r=R[i];
for(int j=l; j<=r; j++) a[j]={l-1, r+1}, c[j]=0;
for(int j=l; j<=r; j++){
while(!e.empty()){
int sz=e.sz()-1;
if(e[sz].ff>v[j])
break;
a[e[sz].ss].ss=j;
e.pop_back();
}
e.pb({v[j], j});
}
e.clear();
for(int j=r; j>=l; j--){
while(!e.empty()){
int sz=e.sz()-1;
if(e[sz].ff>v[j])
break;
a[e[sz].ss].ff=j;
e.pop_back();
}
e.pb({v[j], j});
}
for(int j=l; j<=r; j++){
ll x=j-a[j].ff+1, y=a[j].ss-j;
c[a[j].ff+1]+=v[j]*x;
c[j]-=v[j]*x;
c[j]+=v[j]*y;
c[a[j].ss]-=v[j]*y;
}
for(int j=l; j<=r; j++)
c[j]+=c[j-1];
ll mn=1e18;
for(int j=l; j<=r; j++)
mn=min(mn, c[j]);
ans.pb(mn);
}
return ans;
}
/*
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:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | 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... |