Submission #1306765

#TimeUsernameProblemLanguageResultExecution timeMemory
1306765liangjeremySalesman (IOI09_salesman)C++20
6 / 100
3095 ms27796 KiB
#include<bits/stdc++.h> #include<bits/extc++.h> #define fi first #define se second #define int long long using namespace std; //using namespace __gnu_pbds; using db=double; using ll=int64_t; using sint=__int128; using lb=long double; mt19937 rng(random_device{}()); struct node{ int d; int l; int m; //day loc make }; bool cmp(node a, node b){ return a.d<b.d; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,l,r,s; cin>>n>>l>>r>>s; vector<node>a(n+1); a[0]={0,s,0}; for(int i=1; i<=n; i++){ cin>>a[i].d>>a[i].l>>a[i].m; } sort(a.begin(),a.end(),cmp); vector<int>dp(n+2); a.push_back({(int)1e18,s,0}); for(int i=1; i<=n+1; i++){ for(int j=0; j<i; j++){ if(a[j].l<=a[i].l)dp[i]=max(dp[i],dp[j]+a[i].m-r*(a[i].l-a[j].l)); else if(a[j].l>a[i].l)dp[i]=max(dp[i],dp[j]+a[i].m-l*(a[j].l-a[i].l)); } } cout<<dp.back(); } /* Overhead the albatross hangs motionless upon the air And deep beneath the rolling waves in labyrinths of coral caves The echo of a distant time comes willowing across the sand And everything is green and submarine And no one showed us to the land And no one knows the wheres or whys But something stirs and something tries And starts to climb towards the light */
#Verdict Execution timeMemoryGrader output
Fetching results...