Submission #944166

# Submission time Handle Problem Language Result Execution time Memory
944166 2024-03-12T09:24:32 Z yhkhoo Meetings (IOI18_meetings) C++17
Compilation error
0 ms 0 KB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

/*struct node{
	int s, e, m;
	int val;
	node *l, *r;
	
	node(int S, int E){
		s = S, e = E, m = (s+e)/2;
		val = 0;
		if(s!=e){
			l = new node(s, m);
			r = new node(m+1, e);
		}
	}
	
	void update(int X, int V){
		if(s == X && e == X){
			val = V;
		}
		else{
			if(X <= m) l->update(X, V);
			else r->update(X, V);
			val = l->val + r->val;
		}
	}
	
	int query(int S, int E){*/
		
const ll INF=1e18;

vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
	int N = H.size();
	vector<vector<int>> cost(N);
	for(int i=0; i<N; i++){
		cost[i].reserve(N);
		for(int j=0; j<i; j++){
			cost[i].push_back(cost[j][i]);
		}
		cost[i].push_back(H[i]);
		for(int j=i+1; j<N; j++){
			cost[i].push_back(max(cost[i][j-1], H[j]));
		}
	}
	vector<vector<ll>> pre(N);
	for(int i=0; i<N; i++){
		pre[i].push_back(cost[i][0]);
		for(int j=1; j<N; j++){
			pre[i].push_back(pre[i][j-1] + cost[i][j]);
		}
	}
	vector<ll> ans(Q, INF);
	int Q = L.size();
	for(int i=0; i<Q; i++){
		for(int j=L[i]; j<=R[i]; j++){
			ll cur = pre[j][R[i]];
			if(L[i] != 0){
				cur -= pre[j][L[i]-1];
			}
			ans[i] = min(ans[i], cur);
		}
	}
	return ans;
}

Compilation message

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:56:17: error: 'Q' was not declared in this scope
   56 |  vector<ll> ans(Q, INF);
      |                 ^