Submission #227576

# Submission time Handle Problem Language Result Execution time Memory
227576 2020-04-27T22:04:09 Z blacktulip Triple Jump (JOI19_jumps) C++17
0 / 100
61 ms 19064 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#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 = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 200002;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,l,r,dp[li][5];
int cev;
string s;
vector<int> v;

inline int f(int sira,int hangi,int bas){
	int cevv=-inf;
	if(sira>r){
		if(hangi==2)return 0;
		return -inf;
	}
	if(~dp[sira][hangi])return dp[sira][hangi];
	if(hangi==0){
		cevv=max(cevv,f(sira+1,hangi,bas));
		cevv=max(cevv,f(sira+(sira-bas),1,bas)+a[sira]+a[bas]);
	}
	else{
		cevv=max(cevv,f(sira+1,hangi,bas));
		cevv=max(cevv,f(r+1,2,bas)+a[sira]);
	}
	return dp[sira][hangi]=cevv;
}

main(void){
	
	scanf("%lld",&n);
	FOR scanf("%lld",&a[i]);
	scanf("%lld",&t);
	while(t--){
		memset(dp,-1,sizeof(dp));
		cev=0;
		scanf("%lld %lld",&l,&r);
		for(int i=l;i<=r;i++){
			cev=max(cev,f(i+1,0,i));
		}
		printf("%lld\n",cev);
	}
	return 0;
}

Compilation message

jumps.cpp:49:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
jumps.cpp: In function 'int main()':
jumps.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
jumps.cpp:52:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  FOR scanf("%lld",&a[i]);
      ~~~~~^~~~~~~~~~~~~~
jumps.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&t);
  ~~~~~^~~~~~~~~~~
jumps.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&l,&r);
   ~~~~~^~~~~~~~~~~~~~~~~~~
jumps.cpp:33:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
  if(sira>r){
  ^~
jumps.cpp:33:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
  if(sira>r){
  ^~
jumps.cpp:33:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
  if(sira>r){
  ^~
jumps.cpp:33:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
  if(sira>r){
  ^~
jumps.cpp:33:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
  if(sira>r){
  ^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Incorrect 61 ms 8192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Incorrect 61 ms 8192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 19064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Incorrect 61 ms 8192 KB Output isn't correct
3 Halted 0 ms 0 KB -