# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
780200 | vjudge1 | Go (COCI18_go) | C++17 | 61 ms | 161648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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,k;
ll int dp[101][102][2001];
map<int,int> mp;
ll int hesap(int hangi_pokemon,ll int sn,ll int sonyer){
if(dp[hangi_pokemon][sonyer][sn]!=-1)return dp[hangi_pokemon][sonyer][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];
ll int xxx,yyy,zzz;
if(sonyer!=101)tie(yyy,xxx,zzz)=pokemon[sonyer];
else xxx=k;
if(tim>abs(nerde-xxx)+sn){
b=hesap(hangi_pokemon+1,sn+abs(nerde-xxx),hangi_pokemon)+deg;
}
dp[hangi_pokemon][sonyer][sn]=max(a,b);
return dp[hangi_pokemon][sonyer][sn];
}
int main(){
lalala;
memset(dp,-1,sizeof(dp));
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,101)<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |