# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
120553 |
2019-06-24T21:37:05 Z |
_Samir |
Go (COCI18_go) |
C++17 |
|
296 ms |
173888 KB |
//https://github.com/mostafa-saad/MyCompetitiveProgramming/blob/master/Olympiad/MCO/official/2016/editorial.pdf
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;
int n,m,k,p[110],w[110],e[110],mem[105][105][2][2009];
int dp(int l,int r,int ck,int t)
{
if(l<1||r>m)return 0;
int&ret=mem[l][r][ck][t];
if(~ret)return ret;
ret=0;
if(!ck)
{
ret=max(ret,dp(l-1,r,0,min(2001,abs(p[l]-p[l-1])+t))+(t<e[l]?w[l]:0));
ret=max(ret,dp(l,r+1,1,min(2001,abs(p[l]-p[r+1])+t))+(t<e[l]?w[l]:0));
}
else
{
ret=max(ret,dp(l-1,r,0,min(2001,abs(p[r]-p[l-1])+t))+(t<e[r]?w[r]:0));
ret=max(ret,dp(l,r+1,1,min(2001,abs(p[r]-p[r+1])+t))+(t<e[r]?w[r]:0));
}
return ret;
}
main()
{
//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// char input[15];
// scanf("%s", &input); array of char
// gets(c+1); array of char
//printf("%s, ",name[k[i]].c_str()); printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;
cin>>n>>k>>m;
forr(i,1,m)
cin>>p[i]>>w[i]>>e[i];
p[m+1]=n+100;
memset(mem,-1,sizeof mem);
int ans=0;
forr(i,1,m)
ans=max(ans,dp(i,i,0,abs(p[i]-k)));
cout<<ans<<endl;
return 0;
}
Compilation message
go.cpp:48:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
173688 KB |
Output is correct |
2 |
Correct |
127 ms |
173772 KB |
Output is correct |
3 |
Correct |
126 ms |
173688 KB |
Output is correct |
4 |
Correct |
130 ms |
173688 KB |
Output is correct |
5 |
Correct |
157 ms |
173688 KB |
Output is correct |
6 |
Correct |
155 ms |
173712 KB |
Output is correct |
7 |
Correct |
202 ms |
173660 KB |
Output is correct |
8 |
Correct |
224 ms |
173688 KB |
Output is correct |
9 |
Correct |
254 ms |
173688 KB |
Output is correct |
10 |
Correct |
296 ms |
173888 KB |
Output is correct |