Submission #120552

# Submission time Handle Problem Language Result Execution time Memory
120552 2019-06-24T21:33:40 Z _Samir Go (COCI18_go) C++14
70 / 100
381 ms 173840 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,abs(p[l]-p[l-1])+t)+(t<e[l]?w[l]:0));
       ret=max(ret,dp(l,r+1,1,abs(p[l]-p[r+1])+t)+(t<e[l]?w[l]:0));
    }
    else
    {
       ret=max(ret,dp(l-1,r,0,abs(p[r]-p[l-1])+t)+(t<e[r]?w[r]:0));
       ret=max(ret,dp(l,r+1,1,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 133 ms 173840 KB Output is correct
2 Correct 133 ms 173816 KB Output is correct
3 Correct 131 ms 173688 KB Output is correct
4 Correct 136 ms 173648 KB Output is correct
5 Incorrect 167 ms 173816 KB Output isn't correct
6 Correct 160 ms 173724 KB Output is correct
7 Incorrect 262 ms 173720 KB Output isn't correct
8 Correct 279 ms 173648 KB Output is correct
9 Correct 278 ms 173640 KB Output is correct
10 Incorrect 381 ms 173816 KB Output isn't correct