216562026-01-13 17:46:48algoproBenzinkút üzemeltetés (55)cpp17Compilation error
// UUID: b160b47a-069c-4e25-b3b8-9bdad8cc55d3
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<pair<int, int>> stations(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> stations[i].first >> stations[i].second;
	}
	vector<vector<int>> indexes(n + 1);
	vector<int> dp(n + 1);
	indexes[0]={};
	for(int i = 1; i <= n; i++){
		if(stations[i].first - stations[1].first >= k){
			int prev = 0;
			int maxdist = stations[i].first - k;
			for(int j = 0; stations[j].first <= maxdist; j++){
				prev = j;
			}
			if(dp[i - 1] < stations[i].second + dp[prev]){
				dp[i] = dp[prev] + stations[i].second;
				indexes[i] = indexes[prev];
				indexes[i].push_back(i);
			}
			else{
				dp[i] = dp[i - 1];
				indexes[i] = indexes[i - 1];
			}
				
		}
		else{
			if(dp[i - 1] < stations[i].second){
				dp[i] = dp[prev] + stations[i].second;
				indexes[i] = indexes[prev];
				indexes[i].push_back(i);
			}
			else{
				dp[i] = dp[i - 1];
				indexes[i] = indexes[i - 1];
			}
		}
	}
	cout << dp[n] << endl;
	cout <<  indexes[n].size() << " ";
	for(auto u : indexes[n]){
		cout << u << " ";
	}
}
Compilation error
open /var/local/lib/isolate/422/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:34:43: error: no match for 'operator[]' (operand types are 'std::vector<int>' and '<unresolved overloaded function type>')
   34 |                                 dp[i] = dp[prev] + stations[i].second;
      |                                           ^
In file included from /usr/include/c++/12/vector:64,
                 from /usr/include/c++/12/functional:62,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:71,
                 from main.cpp:2:
/usr/include/c++/12/bits/stl_vector.h:1121:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1121 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/12/bits/stl_vector.h:1121:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1121 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/12/bits/stl_vector.h:1140:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1140 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/12/bits/stl_vector.h:1140:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1140 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
main.cpp:35:53: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '<unresolved overloaded function type>')
   35 |                                 in...