Submission #72051

# Submission time Handle Problem Language Result Execution time Memory
72051 2018-08-26T04:59:25 Z um..(#2163, grape, sssyyy, arpiel0610) Gorgeous Pill (FXCUP3_gorgeous) C++14
0 / 100
2 ms 400 KB
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
#define ll long long

using namespace std;

long long c[300005];
long long d[300005];
long long ans[300005];
bool chk[300005];
int n;
int anss = 0;
void go(int l, int r, int now, int th, int m) {
	
	if (c[now] == th) m += d[now];
	if(l>0) go(l - 1, r, l, th + 1, m);
	if(r<n+1) go(l, r + 1, r, th + 1, m);
	if (l == 0 && r == n + 1) {
		if (anss < m) anss= m;
		return;
	}
	return;
}

int main()
{

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
	}

	for (int i = 1; i <= n; i++) {
		int l = i - 1, r = n - i;
		anss = 0;
		go(i - 1, i+1, i, 1, 0);
		ans[i] = anss;
	}
	printf("%d", ans[1]);
	for (int i = 2; i <= n; i++) printf(" %d", ans[i]);
	printf("\n");


	return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:43:7: warning: unused variable 'l' [-Wunused-variable]
   int l = i - 1, r = n - i;
       ^
gorgeous.cpp:43:18: warning: unused variable 'r' [-Wunused-variable]
   int l = i - 1, r = n - i;
                  ^
gorgeous.cpp:48:21: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d", ans[1]);
               ~~~~~~^
gorgeous.cpp:49:51: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  for (int i = 2; i <= n; i++) printf(" %d", ans[i]);
                                             ~~~~~~^
gorgeous.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &c[i]);
   ~~~~~^~~~~~~~~~~~~~~
gorgeous.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &d[i]);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Incorrect 2 ms 400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Incorrect 2 ms 400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Incorrect 2 ms 400 KB Output isn't correct
4 Halted 0 ms 0 KB -