Submission #79039

#TimeUsernameProblemLanguageResultExecution timeMemory
79039dooweyMeetings (IOI18_meetings)C++14
19 / 100
731 ms398684 KiB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 5005;
ll meet[N][N];

ll pref(int dim, int l, int r){
	ll ans = meet[dim][r];
	if(l != 0)
		ans -= meet[dim][l - 1];
	return ans;
}

vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
	int n = H.size();
	int mx;
	for(int i = 0 ;i < n; i ++ ){
		meet[i][i] = H[i];
		mx = H[i];
		for(int j = i - 1; j >= 0; j -- ){
			mx = max(mx, H[j]);
			meet[i][j] = mx;
		}
		mx = H[i];
		for(int j = i + 1; j < n; j ++ ){
			mx = max(mx, H[j]);
			meet[i][j] = mx;
		}
	}
	for(int i = 0 ; i < n; i ++ ){
		for(int j = 1; j < n; j ++ ){
			meet[i][j] += meet[i][j - 1];
		}
	}
	vector<ll> ans;
	int lf, rf;
	ll tot;
	for(int i = 0; i < L.size(); i ++ ){
		lf = L[i];
		rf = R[i];
		tot = (ll)1e18;
		for(int j = lf; j <= rf; j ++ ){
			tot = min(tot, pref(j, lf, rf));
		}
		ans.push_back(tot);
	}
	return ans;
}

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:41:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < L.size(); i ++ ){
                 ~~^~~~~~~~~~
#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...