# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
152876 | Segtree | 모임들 (IOI18_meetings) | C++14 | 898 ms | 2296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define mod 1000000007
vector<ll> minimum_costs(vector<int> H,vector<int> L,vector<int> R){
vector<ll> anss;
for(int i=0;i<L.size();i++){
ll res[5010];
stack<pair<ll,ll> >s;
ll sum=0;
for(int k=L[i];k<=R[i];k++){
ll cnt=0;
while(!s.empty()&&s.top().first<=H[k]){
cnt+=s.top().second;
sum-=s.top().first*s.top().second;
s.pop();
}
s.push(make_pair(H[k],cnt+1));
sum+=H[k]*(cnt+1);
res[k]=sum;
}
while(!s.empty()){
s.pop();
}
sum=0;
for(int k=R[i];k>=L[i];k--){
ll cnt=0;
while(!s.empty()&&s.top().first<=H[k]){
cnt+=s.top().second;
sum-=s.top().first*s.top().second;
s.pop();
}
s.push(make_pair(H[k],cnt+1));
sum+=H[k]*(cnt+1);
res[k]+=sum;
}
ll ans=1e17;
for(int k=L[i];k<=R[i];k++){
ans=min(ans,res[k]-H[k]);
}
anss.push_back(ans);
}
return anss;
}/*
int main(){
ll n,q; cin>>n>>q;
vector<int> H(n),L(q),R(q);
for(int i=0;i<n;i++)cin>>H[i];
for(int i=0;i<q;i++)cin>>L[i]>>R[i];
vector<ll> ans=minimum_costs(H,L,R);
for(int i=0;i<q;i++)cout<<ans[i]<<endl;
return 0;
}*/
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |