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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:59:12: error: invalid type argument of unary '*' (have 'long long int')
   vp = *v[i];
            ^
input/code.cpp:64:15: error: invalid conversion from 'long long int**' to 'long long int' [-fpermissive]
     v[j] = &vp+c[j];
            ~~~^~~~~
input/code.cpp:66:29: error: no matching function for call to 'min(long long int**, long long int&)'
     v[j] = min(&vp+c[j],v[j]);
                             ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from input/code.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp>...

Code

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

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

	c[0] = 0;

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