Submission #167817

# Submission time Handle Problem Language Result Execution time Memory
167817 2019-12-10T09:30:00 Z blacktulip Kas (COCI17_kas) C++14
70 / 100
527 ms 441032 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 fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo 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 = 500005;
const lo mod = 1000000007;

int n,m,a[li],k,flag,t,dp[55][1005][1005];
int cev;

inline int f(int sira,int sum,int sum1){
	int cevv=0;
	if(sira>n){
		if(sum!=sum1)return -inf;
		return sum;
	}
	if(~dp[sira][sum][sum1])return dp[sira][sum][sum1];
	cevv=max(cevv,f(sira+1,sum+a[sira],sum1));
	cevv=max(cevv,f(sira+1,sum,sum1+a[sira]));
	cevv=max(cevv,f(sira+1,sum,sum1));
	return dp[sira][sum][sum1]=cevv;
}

int main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	FOR{scanf("%d",&a[i]);cev+=a[i];}
	//~ cev=cev/2;
	int yes=f(1,0,0);
	//~ cout<<yes<<endl;
	cev-=yes*2;
	yes+=cev;
	printf("%d\n",yes);
	return 0;
}

Compilation message

kas.cpp: In function 'int main()':
kas.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
kas.cpp:44:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  FOR{scanf("%d",&a[i]);cev+=a[i];}
      ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 179 ms 217796 KB Output is correct
2 Correct 178 ms 217592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 210 ms 217736 KB Output is correct
2 Correct 209 ms 217820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 217740 KB Output is correct
2 Correct 183 ms 217740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 217708 KB Output is correct
2 Correct 212 ms 217720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 217824 KB Output is correct
2 Correct 222 ms 217932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 217808 KB Output is correct
2 Correct 195 ms 217720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 261 ms 217872 KB Output is correct
2 Correct 246 ms 217680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 527 ms 440280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 440 ms 441032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 465 ms 441012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -