Submission #6104728


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=924844033;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int p[1100];
int dp[2][1100];
int n;
long long ch;
int calc(int a,int b){
	if(dp[a][b]!=mod)return dp[a][b];
	if(b==n)return dp[a][b]=0;
	int ret=1100;
	if(a==0)ret=-ret;
	long long cur=0;
	for(int i=b;i<n;i++){
		cur+=p[i];
		int th=1;
		if(cur<ch)th=-1;
		if(a==0){
			ret=max(ret,th+calc(!a,i+1));
		}else{
			ret=min(ret,th+calc(!a,i+1));
		}
	}
	return dp[a][b]=ret;
}
int main(){
	int a;scanf("%d",&a);
	n=a;
	for(int i=0;i<a;i++)scanf("%d",p+i);
	long long left=-10000000000000LL;
	long long right=10000000000000LL;
	while(left+1<right){
		long long M=(left+right)/2;
		ch=M;
		for(int i=0;i<=a;i++)dp[0][i]=dp[1][i]=mod;
		int t=calc(0,0);
		if(t>=0){
			left=M;
		}else right=M;
	}
	printf("%lld\n",left);
}

Submission Info

Submission Time
Task H - Median Game
User tozangezan
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1333 Byte
Status AC
Exec Time 129 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:49:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a;scanf("%d",&a);
                      ^
./Main.cpp:51:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<a;i++)scanf("%d",p+i);
                                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 32
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 128 KB
02.txt AC 1 ms 128 KB
03.txt AC 1 ms 128 KB
04.txt AC 1 ms 128 KB
05.txt AC 1 ms 128 KB
06.txt AC 1 ms 128 KB
07.txt AC 1 ms 128 KB
08.txt AC 1 ms 128 KB
09.txt AC 1 ms 128 KB
10.txt AC 1 ms 128 KB
11.txt AC 127 ms 256 KB
12.txt AC 121 ms 256 KB
13.txt AC 106 ms 256 KB
14.txt AC 119 ms 256 KB
15.txt AC 110 ms 256 KB
16.txt AC 121 ms 256 KB
17.txt AC 125 ms 256 KB
18.txt AC 115 ms 256 KB
19.txt AC 121 ms 256 KB
20.txt AC 121 ms 256 KB
21.txt AC 116 ms 256 KB
22.txt AC 120 ms 256 KB
23.txt AC 118 ms 256 KB
24.txt AC 117 ms 256 KB
25.txt AC 123 ms 256 KB
26.txt AC 117 ms 256 KB
27.txt AC 116 ms 256 KB
28.txt AC 129 ms 256 KB
29.txt AC 118 ms 256 KB
30.txt AC 123 ms 256 KB
s1.txt AC 1 ms 128 KB
s2.txt AC 1 ms 128 KB