이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "meetings.h"
//#include "grader.cpp"
#define ll long long
#define pb push_back
#define sz size
#define fst first
#define scd second
#define vl vector<ll>
#define vi vector<int>
#define ii pair<int,int>
using namespace std;
vl minimum_costs(vi H, vi L,vi R) {
vl ret;
for(int i=0;i<L.sz();i++){
deque<ii>dq;
vl a1,a2;
ll sum=0;
for(int j=L[i];j<=R[i];j++){
int x=H[j];
ii to={x,1};
while(dq.sz()&& dq[0].fst<=to.fst ){
sum-=dq[0].fst*dq[0].scd;
to.scd+=dq[0].scd;
dq.pop_front();
}
sum+=to.fst*to.scd;
dq.push_front(to);
a1.pb(sum);
}
dq.clear();
sum=0;
for(int j=R[i];j>=L[i];j--){
int x=H[j];
ii to={x,1};
while(dq.sz()&& dq[0].fst<=to.fst ){
sum-=dq[0].fst*dq[0].scd;
to.scd+=dq[0].scd;
dq.pop_front();
}
sum+=to.fst*to.scd;
dq.push_front(to);
a2.pb(sum);
}
ll ans=1e18;
reverse(a2.begin(),a2.end());
for(int j=0;j<a1.sz();j++){
ll ai=a1[j];
if( j+1 != a1.sz() ){
ai+=a2[j+1];
}
ans=min(ans,ai);
}
ret.pb(ans);
// cout<<ans<<endl;
}
return ret;
}
//
//int main(){
//
// vi ans=minimum_costs({5,3,1,4,6,3,5,7,1},{0,1,3,3},{8,4,6,8});
//
//return 0;}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=0;i<L.sz();i++){
| ~^~~~~~~
meetings.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int j=0;j<a1.sz();j++){
| ~^~~~~~~~
meetings.cpp:61:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | if( j+1 != a1.sz() ){
| ~~~~^~~~~~~~~~
# | 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... |