# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
660420 |
2022-11-21T19:32:37 Z |
Ahmed57 |
Go (COCI18_go) |
C++14 |
|
449 ms |
524288 KB |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> v;
int m,n,k;
long long dp[101][101][2001][2];
long long solve(int l,int r,int ti,int tu){
if(ti>2000)return 0;
if(dp[l][r][ti][tu]!=-1)return dp[l][r][ti][tu];
int ind = 0;
if(l+1==r){
ind = m;
}else {
if(tu==0){
ind = v[l+1][0];
}else{
ind = v[r-1][0];
}
}
long long c1 = 0;
if(l>=0){
int ne = ti+abs(v[l][0]-ind);
c1 = max(c1,solve(l-1,r,ne,0)+(ne<=v[l][2]?v[l][1]:0));
}if(r<m){
int ne = ti+abs(v[r][0]-ind);
c1 = max(c1,solve(l,r+1,ne,1)+(ne<=v[r][2]?v[r][1]:0));
}
return dp[l][r][ti][tu] = c1;
}
int main(){
cin>>n>>k>>m;
int u = m;
for(int i = 0;i<m;i++){
long long a,b,c;cin>>a>>b>>c;
v.push_back({a,b,c});
if(a>=m&&u==m){
u = i;
}
}
memset(dp,-1,sizeof dp);
cout<<solve(u-1,u,1,0);
}
Compilation message
go.cpp: In function 'int main()':
go.cpp:35:22: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
35 | v.push_back({a,b,c});
| ^
go.cpp:35:22: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
go.cpp:35:24: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
35 | v.push_back({a,b,c});
| ^
go.cpp:35:24: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
go.cpp:35:26: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
35 | v.push_back({a,b,c});
| ^
go.cpp:35:26: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
365 ms |
524288 KB |
Execution killed with signal 11 |
2 |
Runtime error |
391 ms |
524288 KB |
Execution killed with signal 11 |
3 |
Runtime error |
385 ms |
524288 KB |
Execution killed with signal 11 |
4 |
Runtime error |
384 ms |
524288 KB |
Execution killed with signal 11 |
5 |
Runtime error |
426 ms |
524288 KB |
Execution killed with signal 11 |
6 |
Runtime error |
398 ms |
524288 KB |
Execution killed with signal 11 |
7 |
Runtime error |
373 ms |
524288 KB |
Execution killed with signal 11 |
8 |
Runtime error |
403 ms |
524288 KB |
Execution killed with signal 11 |
9 |
Runtime error |
449 ms |
524288 KB |
Execution killed with signal 11 |
10 |
Runtime error |
406 ms |
524288 KB |
Execution killed with signal 11 |