# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780120 | vjudge1 | Go (COCI18_go) | C++17 | 1 ms | 1972 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 N 200005
// süre nerde pokemon_deg
vector<tuple<ll int,ll int,ll int>> pokemon;
int n,m;
ll int dp[105][2005];
ll int hesap(int hangi_pokemon,ll int sn,ll int sonyer){
if(dp[hangi_pokemon][sn]!=-1)return dp[hangi_pokemon][sn];
if(hangi_pokemon>=m)return 0;
ll int a=hesap(hangi_pokemon+1,sn,sonyer);
ll int b=0;
ll int nerde,deg,tim;
tie(tim,nerde,deg)=pokemon[hangi_pokemon];
if(tim>abs(nerde-sonyer)+sn){
b=hesap(hangi_pokemon+1,sn+abs(nerde-sonyer),nerde)+deg;
}
//cout<<hangi_pokemon<<" "<<sn<<" "<<sonyer<<" "<<a<<" "<<b<<endl;
dp[hangi_pokemon][sn]=max(a,b);
return dp[hangi_pokemon][sn];
}
int main(){
lalala;
memset(dp,-1,sizeof(dp));
int k;cin>>n>>k>>m;
for(int i=0;i<m;i++){
ll int a,b,c;cin>>a>>b>>c;
pokemon.pb({c,a,b});
}
sort(pokemon.begin(),pokemon.end());
cout<<hesap(0,0,k)<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |