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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:5:2: error: 'ios_base' has not been declared
  ios_base::sync_with_stdio(false);
  ^~~~~~~~
input/code.cpp:6:2: error: 'cin' was not declared in this scope
  cin.tie(NULL);
  ^~~
input/code.cpp:6:2: note: suggested alternative: 'main'
  cin.tie(NULL);
  ^~~
  main
input/code.cpp:6:10: error: 'NULL' was not declared in this scope
  cin.tie(NULL);
          ^~~~
input/code.cpp:26:26: error: 'min' was not declared in this scope
   for (int j = i+1; j <= min(i+d[i],n); j++) {
                          ^~~
input/code.cpp:26:26: note: suggested alternative: 'main'
   for (int j = i+1; j <= min(i+d[i],n); j++) {
                          ^~~
                          main
input/code.cpp:36:2: error: 'cout' was not declared in this scope
  cout << 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;
	cin >> n;
	int d[n];
	long c[n];
	long v[n];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	c[0] = 0;
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}
	
	d[n] = 0;
	c[n] = 0;
	
	v[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j <= min(i+d[i],n); j++) {
			if (j > etenema) {
				etenema = j;
				v[j] = v[i]+c[j];
			} else {
				v[j] = min(v[i]+c[j],v[j]);
			}
		}
	}

	cout << v[n];
}