# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
120551 |
2019-06-24T21:30:18 Z |
_Samir |
Go (COCI18_go) |
C++14 |
|
134 ms |
173816 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;
if(ck==0&&e[l]<=t)return 0;
if(ck==1&&e[r]<=t)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,abs(p[l]-p[l-1])+t)+w[l]);
ret=max(ret,dp(l,r+1,1,abs(p[l]-p[r+1])+t)+w[l]);
}
else
{
ret=max(ret,dp(l-1,r,0,abs(p[r]-p[l-1])+t)+w[r]);
ret=max(ret,dp(l,r+1,1,abs(p[r]-p[r+1])+t)+w[r]);
}
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:50:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
128 ms |
173712 KB |
Output isn't correct |
2 |
Incorrect |
125 ms |
173816 KB |
Output isn't correct |
3 |
Incorrect |
130 ms |
173652 KB |
Output isn't correct |
4 |
Incorrect |
130 ms |
173632 KB |
Output isn't correct |
5 |
Incorrect |
129 ms |
173788 KB |
Output isn't correct |
6 |
Incorrect |
130 ms |
173688 KB |
Output isn't correct |
7 |
Incorrect |
132 ms |
173696 KB |
Output isn't correct |
8 |
Incorrect |
129 ms |
173688 KB |
Output isn't correct |
9 |
Incorrect |
131 ms |
173688 KB |
Output isn't correct |
10 |
Incorrect |
134 ms |
173768 KB |
Output isn't correct |