Submission #821900

#TimeUsernameProblemLanguageResultExecution timeMemory
821900LiudasSalesman (IOI09_salesman)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int N, U, D, S; struct node{ int pos; int pro; int day; bool operator<(node a){ if(day == a.day){ return abs(pos-S) < abs(a.pos-S); } return day < a.day; } }; int main() { cin >> N >> U >> D >> S; vector<node> arr(N+1, {0, 0, 0}); arr[0].day = -1; arr[0].pos = S; if(N > 5000){ return; } for(int i = 1; i <= N; i ++){ cin >> arr[i].day >> arr[i].pos >> arr[i].pro; } sort(arr.begin(), arr.end()); vector<int> DP(N+1); for(int i = 1; i <= N; i ++){ int mx = -1e9; for(int j = 0; j < i; j ++){ mx = max(mx, -(arr[j].pos - arr[i].pos > 0 ? (arr[j].pos - arr[i].pos) * D : -(arr[j].pos - arr[i].pos) * U) + DP[j]); } DP[i] += mx + arr[i].pro; } int ans = 0; for(int i = 0; i <= N; i ++){ ans = max(ans, DP[i] - (S - arr[i].pos > 0 ? (S - arr[i].pos) * U : -(S - arr[i].pos) * D)); } cout << ans << endl; return 0; }

Compilation message (stderr)

salesman.cpp: In function 'int main()':
salesman.cpp:22:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   22 |         return;
      |         ^~~~~~