답안 #203529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203529 2020-02-21T06:36:19 Z blacktulip Semiexpress (JOI17_semiexpress) C++17
0 / 100
40 ms 71032 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#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 MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 100000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b,c,a,k,flag,t,vis[li],dp[3005][3005];
int cev,ans;
string s;
set<int> st,st1;
vector<int> v;

inline int f(int sira,int kac){
	//~ cout<<sira<<" : : "<<kac<<endl;
	int cevv=-inf;
	if(kac<0)return -inf;
	if(sira>n){
		if(kac!=0)return -inf;
		return 0;
	}
	if(~dp[sira][kac])return dp[sira][kac];
	if(vis[sira]){
		//~ cout<<"**\n";
		int bas=sira;
		int son=0;
		if(vis[sira]+1<(int)v.size())
			son=v[vis[sira]+1]-1;
		else son=n;
		while(bas<=son){
			if((sira-1)*b+(ort-sira)*a>t)son=ort-1;
			else bas=ort+1;
		}
		
		//~ cout<<"***\n";
		if(son<sira)cevv=max(cevv,f(sira+1,kac));
		else cevv=max(cevv,f(son+1,kac)+son-sira+1);
		
	}
	else{
		//~ cout<<"()\n";
		cevv=max(cevv,f(sira+1,kac));
		auto it1=st.upper_bound(sira);
		auto it=it1;
		//~ if(it==st.begin())cout<<"one\n";
		it--;
		int bas=sira;
		int son=0;
		if(it1!=st.end())
			son=*it1-1;
		else son=n-1;
		//~ if(sira==5)cout<<son<<"yess"<<*it1<<endl;
		while(bas<=son){
			if(sira==8){
				//~ cout<<bas<<" ()() "<<son<<" ()() "<<ort<<" ()() "<<(*it-1)*b+(sira-*it)*c+(ort-sira)*a<<"DEBUG"<<endl;
			}
			if((*it-1)*b+(sira-*it)*c+(ort-sira)*a>t)son=ort-1;
			else bas=ort+1;
		}
		//~ cout<<sira<<" : : "<<son<<endl;
		if(son<sira)cevv=max(cevv,f(sira+1,kac-1));
		if(son<sira)cevv=max(cevv,f(sira+1,kac));
		else cevv=max(cevv,f(son+1,kac-1)+son-sira+1);
		
	}
	return dp[sira][kac]=cevv;
}

main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld %lld",&n,&m,&k);
	scanf("%lld %lld %lld",&a,&b,&c);
	scanf("%lld",&t);
	for(int i=1;i<=m;i++){
		int x;
		scanf("%lld",&x);
		vis[x]=i;
		v.pb(x);
		st.insert(x);
		k--;
	}
	cev=f(1,k);
	printf("%lld\n",--cev);
	return 0;
}

Compilation message

semiexpress.cpp:87:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:89:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:90:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&a,&b,&c);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:91:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&t);
  ~~~~~^~~~~~~~~~~
semiexpress.cpp:94:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 71032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 71032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 71032 KB Output isn't correct
2 Halted 0 ms 0 KB -