Submission #780837

#TimeUsernameProblemLanguageResultExecution timeMemory
780837DangerNoodle7591Go (COCI18_go)C++17
100 / 100
198 ms326368 KiB
#include<bits/stdc++.h> using namespace std; #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL); //#define endl "\n" #define ll long long #define pb push_back #define M 102 ll int deg[M],yer[M],dak[M]; ll int n,m,k; ll int dp[2][2002][M][M]; ll int hesap(int nerde,ll int sn,int left,int right){ if(sn>2000)return 0; if(left<0||right>=m)return 0; if(dp[nerde][sn][left][right]!=-1)return dp[nerde][sn][left][right]; ll int a=0,b=0; if(nerde==0){//leftteyim if(left>0){ a=hesap(nerde,sn+abs(yer[left]-yer[left-1]),left-1,right); if(abs(yer[left]-yer[left-1])+sn<dak[left-1])a+=deg[left-1]; } if(right<m-1){ b=hesap(1,sn+abs(yer[left]-yer[right+1]),left,right+1); if(abs(yer[left]-yer[right+1])+sn<dak[right+1])b+=deg[right+1]; } //cout<<nerde<<" "<<a<<" "<<b<<" "<<sn<<" "<<left<<" "<<right<<endl; return dp[nerde][sn][left][right]=max(a,b); } if(left>0){ a=hesap(0,sn+abs(yer[right]-yer[left-1]),left-1,right); if(abs(yer[right]-yer[left-1])+sn<dak[left-1])a+=deg[left-1]; } if(right<m-1){ b=hesap(1,sn+abs(yer[right]-yer[right+1]),left,right+1); if(abs(yer[right]-yer[right+1])+sn<dak[right+1])b+=deg[right+1]; } //cout<<nerde<<" "<<a<<" "<<b<<" "<<sn<<" "<<left<<" "<<right<<endl; return dp[nerde][sn][left][right]=max(a,b); } int main(){ memset(dp,-1,sizeof(dp)); cin>>n>>k>>m; int yes=0; ll int cev=0; int l=-1,r=-1; for(int i=0;i<m;i++){ cin>>yer[i]>>deg[i]>>dak[i]; if(yer[i]<k)l=i; else if(r==-1)r=i; } ll int a=0,b=0; if(l!=-1){ a=hesap(0,abs(k-yer[l]),l,l); if(abs(k-yer[l])<dak[l])a+=deg[l]; } if(r!=-1){ b=hesap(1,abs(k-yer[r]),r,r); if(abs(k-yer[r])<dak[r])b+=deg[r]; } cout<<max(a,b)<<endl; }

Compilation message (stderr)

go.cpp: In function 'int main()':
go.cpp:42:6: warning: unused variable 'yes' [-Wunused-variable]
   42 |  int yes=0;
      |      ^~~
go.cpp:43:9: warning: unused variable 'cev' [-Wunused-variable]
   43 |  ll int cev=0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...