Submission #733417

#TimeUsernameProblemLanguageResultExecution timeMemory
733417penguin133Salesman (IOI09_salesman)C++17
6 / 100
3078 ms21240 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, u, d, s; int dp[500005]; pii A[500005]; void solve(){ cin >> n >> u >> d >> s; for(int i=1;i<=n;i++){ cin >> A[i].fi >> A[i].se.fi >> A[i].se.se; } sort(A+1, A+n+1); A[0].se.fi = s; A[n+1].se.fi = s; for(int i=1;i<=n+1;i++){ for(int j=i-1;j>=0;j--){ int cst; if(A[j].se.fi > A[i].se.fi)cst = d * (A[j].se.fi - A[i].se.fi); else cst = u * (A[i].se.fi - A[j].se.fi); dp[i] = max(dp[i], dp[j] - cst + A[i].se.se); } } cout << dp[n+1]; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

salesman.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...