Submission #72051

#TimeUsernameProblemLanguageResultExecution timeMemory
72051um.. (#118)놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous)C++14
0 / 100
2 ms400 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...