제출 #836267

#제출 시각아이디문제언어결과실행 시간메모리
836267Mohmad_ZaidMeetings (IOI18_meetings)C++17
0 / 100
3155 ms786432 KiB
// #include "meetings.h"
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define print(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
using namespace std;
vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
    int q = L.size();
    int n = H.size();
    vector<vector<ll>>prefix(n,vector<ll>(n+1,0));
    for(int i=0;i<n;i++){
        ll mx=0;
        for (int j=i;j<n;j++){
            mx=max(mx,(ll)H[j]);
            prefix[i][j+1]=prefix[i][j]+mx;
            // cout<<prefix[i][j+1]<<" ";
        }
        // cout<<endl;
    }
    
    vector<long long> C(q);
    for(int i=0;i<q;i++){
        ll mx=0;
        ll mn=LONG_LONG_MAX;
        vector<ll>maxs(n,0);
        for(int j=L[i];j<=R[i];j++){
            mx=max(mx,(ll)H[j]);
            maxs[j]=mx;
        }
        // for(int j=0;j<n;j++)cout<<maxs[j]<<' ';cout<<endl;
        for(int j=L[i];j<=R[i];j++){
            ll sm=0;
            // sm+=H[j];
            // if(j!=L[i]){
            sm+=maxs[j]*(j-L[i]);
            // }
            sm+=prefix[j][R[i]+1]-prefix[j][j];
            mn=min(mn,sm);
        }
        C[i]=mn;
    }
    return C;
}
// int main(){
//     vector<ll>c;
//     c=minimum_costs({2,4,3,5,4}, {0,1,0}, {2,3,4});
//     print(c);
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...