3744 | 2023-03-02 18:26:46 | hackemon | Benzinkút üzemeltetés (55) | csharp | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> v(n), d(n); // value and distance
vector<int> dp(n), pr(n); // dp and previous element
for(int i = 0 ;i< n;i++ ) {
cin >> d[i] >> v[i];
dp[i] = v[i];
}
for(int i = 0;i< n;i++ ) {
for(int j = 0;j< i;j++ ) {
if(dp[i] < dp[j] + v[i] && d[i] - d[j] >= k) {
dp[i] = dp[j] + v[i];
pr[i] = j;
}
}
}
int ma = 0;
int pos = 0;
for(int i = 0;i< n;i++ ) {
if(dp[i] > ma) {
ma = dp[i];
pos = i;
}
}
cout << ma << endl;
stack<int> pozicio;
while(pr[pos] != pos) {
pozicio.push(pos+1);
pos = pr[pos];
}
cout << pozicio.size() << ' ';
while(!pozicio.empty()) {
cout << pozicio.top() << ' ';
pozicio.pop();
}
cout << endl;
return 0;
}
exit status 1
Compilation failed: 7 error(s), 0 warnings
main.cs(2,0): error CS1024: Wrong preprocessor directive
main.cs(2,6): error CS1525: Unexpected symbol `namespace', expecting `identifier' or `static'
main.cs(2,19): error CS1525: Unexpected symbol `;', expecting `identifier' or `static'
main.cs(6,4): error CS1525: Unexpected symbol `int', expecting `identifier' or `static'
main.cs(12,8): error CS1525: Unexpected symbol `cin', expecting `identifier' or `static'
main.cs(12,17): error CS1514: Unexpected symbol `[', expecting `.' or `{'
main.cs(12,20): error CS1525: Unexpected symbol `>>'
Exited with error status 1