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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:58:5: error: expected ';' before 'if'
     if (etenema == n && tv > v[n])
     ^~

Code

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	int etenema = 0;
	int d[200001];
	int c[200001];
	long long v[200001];
	long long tv;
	int t;

	c[0] = 0;

	string line;
	getline(cin, line);
	stringstream split_n(line);
	split_n >> n;

	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];
		t = min(i+d[i],n);
		if (v[i] < v[n]) {
			for (int j = i+1; j <= t; j++) {
				tv = v[i]+c[j]
				if (etenema == n && tv > v[n])
					continue;
				if (j > etenema) {
					split_c >> c[j];
					etenema = j;
					v[j] = tv;
				} else {
					v[j] = min(tv,v[j]);
				}
			}
		}
	}
	// for (auto val : v)
		// cout << val << " ";
	cout << v[n];
}