답안 #120550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120550 2019-06-24T21:23:38 Z _Samir Go (COCI18_go) C++17
0 / 100
121 ms 164004 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[102][102][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)
{
    if(p[i]<k&&p[i+1]>k)ans=max(ans,dp(i,i,0,abs(p[i]-k)));
    if(p[i]>k&&p[i-1]<k)ans=max(ans,dp(i,i,0,abs(p[i]-k)));
    if(p[i]==k)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()
       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 163988 KB Output isn't correct
2 Incorrect 120 ms 163992 KB Output isn't correct
3 Incorrect 118 ms 164000 KB Output isn't correct
4 Incorrect 119 ms 163948 KB Output isn't correct
5 Incorrect 121 ms 163956 KB Output isn't correct
6 Incorrect 116 ms 164004 KB Output isn't correct
7 Incorrect 119 ms 163960 KB Output isn't correct
8 Incorrect 121 ms 163964 KB Output isn't correct
9 Incorrect 119 ms 163992 KB Output isn't correct
10 Incorrect 116 ms 163960 KB Output isn't correct