Submission #1073746

# Submission time Handle Problem Language Result Execution time Memory
1073746 2024-08-24T19:53:04 Z shezitt Meetings (IOI18_meetings) C++14
4 / 100
4373 ms 2908 KB
#include <bits/stdc++.h>
#include "meetings.h"

using ll = long long;

#define fore(a, b, c) for(int a=b; a<c; ++a)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

using namespace std;

int T[6050], n;

void update(int idx, int x){
    T[idx += n] = x;
    for(idx /= 2; idx; idx /= 2){
        T[idx] = max(T[2*idx], T[2*idx+1]);
    }
}

int query(int low, int high){
    int ra = 0, rb = 0;
    for(low += n, high += n + 1; low < high; low /= 2, high /= 2){
        if(low & 1) ra = max(ra, T[low++]);
        if(high & 1) rb = max(rb, T[--high]);
    }
    return max(ra, rb);
}

std::vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {

    int Q = L.size();
    vector<ll> C(Q);

    int N = 0;

    for (int j = 0; j < Q; ++j) {
        N = max(N, R[j]);
    }

    N++;
    assert(N<=3000);
    n = N;

    for(int i=0; i<N; ++i){
        update(i, H[i]);
    }

    for(int j=0; j<Q; ++j){
        int l = L[j], r = R[j];

        ll ans = 4e18;
        for(int x=l; x<=r; ++x){
            ll cur = 0;
            for(int i=l; i<=r; ++i){
                cur += query(min(i,x), max(i,x));
            }
            ans = min(ans, cur);
        }

        C[j] = ans;

    }

  
    return C;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 640 ms 344 KB Output is correct
3 Correct 4305 ms 460 KB Output is correct
4 Correct 1273 ms 344 KB Output is correct
5 Correct 4293 ms 344 KB Output is correct
6 Correct 418 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 130 ms 348 KB Output is correct
9 Correct 4373 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 640 ms 344 KB Output is correct
3 Correct 4305 ms 460 KB Output is correct
4 Correct 1273 ms 344 KB Output is correct
5 Correct 4293 ms 344 KB Output is correct
6 Correct 418 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 130 ms 348 KB Output is correct
9 Correct 4373 ms 456 KB Output is correct
10 Runtime error 2 ms 856 KB Execution killed with signal 6
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 9 ms 2908 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 9 ms 2908 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 640 ms 344 KB Output is correct
3 Correct 4305 ms 460 KB Output is correct
4 Correct 1273 ms 344 KB Output is correct
5 Correct 4293 ms 344 KB Output is correct
6 Correct 418 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 130 ms 348 KB Output is correct
9 Correct 4373 ms 456 KB Output is correct
10 Runtime error 2 ms 856 KB Execution killed with signal 6
11 Halted 0 ms 0 KB -