Submission #821894

#TimeUsernameProblemLanguageResultExecution timeMemory
821894LiudasSalesman (IOI09_salesman)C++17
17 / 100
3090 ms17028 KiB
#include <bits/stdc++.h> using namespace std; struct node{ int pos; int pro; int day; bool operator<(node a){ return day < a.day; } }; int main() { int N, U, D, S; cin >> N >> U >> D >> S; vector<node> arr(N+1, {0, 0, 0}); arr[0].day = -1; arr[0].pos = S; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...