# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
780302 |
2023-07-12T08:04:22 Z |
vjudge1 |
Go (COCI18_go) |
C++17 |
|
87 ms |
169972 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000;
const lo li = 1001;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t[li],b[li],dp[1002][104][104][4];
int cev;
string s;
vector<int> v;
inline int in(){
int x;
scanf("%d",&x);
return x;
}
inline int f(int tim,int l,int r,int deg,int kim){
int cevv=0;
if(l<=1 && r>=m)return 0;
//~ cout<<tim<<" () "<<l<<" () "<<r<<" () "<<kim<<" () "<<t[l-1]<<endl;
if(~dp[deg][l][r][kim])return dp[deg][l][r][kim];
if(kim==0){
if(l>1){
cevv=max(cevv,f(tim+a[l]-a[l-1],l-1,r,0,deg)+(tim+a[l]-a[l-1]<t[l-1]?b[l-1]:0));
}
if(r<m){
cevv=max(cevv,f(tim+a[r+1]-a[l],l,r+1,1,deg+1)+(tim+a[r+1]-a[l]<t[r+1]?b[r+1]:0));
}
}
else{
if(l>1){
cevv=max(cevv,f(tim+a[r]-a[l-1],l-1,r,0,deg+1)+(tim+a[r]-a[l-1]<t[l-1]?b[l-1]:0));
}
if(r<m){
cevv=max(cevv,f(tim+a[r+1]-a[r],l,r+1,1,deg)+(tim+a[r+1]-a[r]<t[r+1]?b[r+1]:0));
}
}
return dp[deg][l][r][kim]=cevv;
}
int main(void){
n=in(),k=in(),m=in();
memset(dp,-1,sizeof(dp));
for(int i=1;i<=m;i++){
a[i]=in(),b[i]=in(),t[i]=in();
}
int l=0,r=0;
for(int i=1;i<=m;i++){
if(a[i]<=k){l=i;r=i+1;}
}
int at=f(k-a[l],l,l,0,0)+(k-a[l]<t[l]?b[l]:0);
memset(dp,-1,sizeof(dp));
int kat=f(a[r]-k,r,r,1,0)+(a[r]-k<t[r]?b[r]:0);
if(l==0)at=0;
if(r==m+1)at=0;
printf("%d\n",max(at,kat));
return 0;
}
Compilation message
go.cpp: In function 'int in()':
go.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | scanf("%d",&x);
| ~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
169960 KB |
Output isn't correct |
2 |
Correct |
65 ms |
169960 KB |
Output is correct |
3 |
Correct |
84 ms |
169936 KB |
Output is correct |
4 |
Correct |
65 ms |
169964 KB |
Output is correct |
5 |
Incorrect |
85 ms |
169968 KB |
Output isn't correct |
6 |
Correct |
75 ms |
169932 KB |
Output is correct |
7 |
Incorrect |
87 ms |
169972 KB |
Output isn't correct |
8 |
Correct |
68 ms |
169868 KB |
Output is correct |
9 |
Correct |
85 ms |
169972 KB |
Output is correct |
10 |
Correct |
67 ms |
169972 KB |
Output is correct |