Submission #70758

# Submission time Handle Problem Language Result Execution time Memory
70758 2018-08-23T10:10:59 Z 검수컵(#1978, imsifile) Gorgeous Pill (FXCUP3_gorgeous) C++
12 / 100
1500 ms 564 KB
#include<stdio.h>

typedef long long lld;
int N, ba[303030]; lld dmg[303030], mx;

void dfs(int th, int l, int r, lld sco){
	if(th>N){
		if(mx<sco) mx=sco;
		return;
	}
	if(l>=0) dfs(th+1, l-1, r, sco + (ba[l]==th ? dmg[l] : 0));
	if(r<=N-1) dfs(th+1, l, r+1, sco + (ba[r]==th ? dmg[r] : 0));
}

int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++) scanf("%d", &ba[i]);
	for(int i=0; i<N; i++) scanf("%lld", &dmg[i]);
	for(int i=0; i<N; i++){
		mx=0;
		dfs(2, i-1, i+1, ba[i]==1 ? dmg[i] : 0);
		printf("%lld ", mx);
	}
	return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:17:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++) scanf("%d", &ba[i]);
                         ~~~~~^~~~~~~~~~~~~~
gorgeous.cpp:18:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++) scanf("%lld", &dmg[i]);
                         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Execution timed out 1568 ms 564 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Execution timed out 1568 ms 564 KB Time limit exceeded
8 Halted 0 ms 0 KB -