Submission #1074242

#TimeUsernameProblemLanguageResultExecution timeMemory
1074242TB_Meetings (IOI18_meetings)C++17
4 / 100
5584 ms1944 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fo(i, n) for(ll i = 0; i<(n); i++)
#define pb push_back
#define F first
#define S second
#define deb(x) cout << #x << " = " << (x) << endl 
#define deb2(x, y) cout << #x << " = " << (x)  << ", " << #y << " = " << (y) << endl 
typedef vector<ll> vl;
typedef vector<vl> vvl;



vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
    int q = L.size();
    ll n = H.size();
    vl C;
    fo(ind, q){
        ll best = 1e18;
        for(ll meet = L[ind]; meet<=R[ind]; meet++){
            ll hi = H[meet];
            ll current = -hi;
            for(ll i = meet; i>=L[ind]; i--){
                hi = max(hi, (ll)H[i]);
                current+=hi;
            }
            hi = H[meet];
            for(ll i = meet; i<=R[ind]; i++){
                hi = max(hi, (ll)H[i]);
                current+=hi;
            }
            best=min(best, current);
            // deb2(current, meet);
        }
        C.pb(best);
    }
    // fo(i, q) deb(C[i]);
    return C;
}



// int main(){

//     vector<int> a = {2, 4, 3, 5};
//     vector<int> b = {0, 1};
//     vector<int> c = {2, 3};
//     minimum_costs(a, b, c);

//     return 0;
// }


Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:19:8: warning: unused variable 'n' [-Wunused-variable]
   19 |     ll n = H.size();
      |        ^
#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...