CSES - Datatähti 2020 alku - Results
Submission details
Task:Mastot
Sender:ph
Submission time:2019-10-13 19:47:29 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:52:12: error: 'etenema' was not declared in this scope
    if (j > etenema) {
            ^~~~~~~

Code

#include<bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	// int etenema = 0;
	string line;
	getline(cin, line);
	stringstream split_n(line);
	split_n >> n;
	int d[200001];
	int c[200001];
	long long v[200001];

	c[0] = 0;

	getline(cin, line);
	stringstream split_d(line);
	getline(cin, line);
	stringstream split_c(line);
	
	// split_d >> d[0];
	// int i = 1;
	// while (i < n) {
		// split_d >> d[i];
		// split_c >> c[i];
		// v[i] = LLONG_MAX;
		// i++;
	// }
	// v[n] = LLONG_MAX;
	d[n] = 0;
	c[n] = 0;
	
	v[0] = 0;
	// i = 0; 
	// while (i < n) {
		// int j = i+1;
		// int t = min(i+d[i],n);
		// while (j <= t) {
			// v[j] = (v[j] > v[i]+c[j]) ? v[i]+c[j] : v[j];
			// j++;
		// }
		// i++;
	// }

	
	for (int i = 0; i < n; i++) {
		split_d >> d[i];
		for (int j = i+1; j <= min(i+d[i],n); j++) {
			if (j > etenema) {
				split_c >> c[j];
				etenema = j;
				v[j] = v[i]+c[j];
			} else {
				v[j] = min(v[i]+c[j],v[j]);
			}
		}
	}
	// for (auto val : v)
		// cout << val << " ";
	cout << v[n];
}