Submission #38455

#TimeUsernameProblemLanguageResultExecution timeMemory
3845514kgBiochips (IZhO12_biochips)C++11
100 / 100
209 ms399104 KiB
#include <stdio.h> #include <vector> #define N 200002 #define INF 2000000000 #define max2(x,y) (x>y?x:y) using namespace std; int n, m, dp_lev; int dp[N][501], in[N]; vector<int> r[N]; void f(int x) { int temp = dp_lev; for (auto i : r[x]) f(i); dp_lev++; for (int i = 1; i <= m; i++) dp[dp_lev][i] = max2(dp[dp_lev - 1][i], dp[temp][i - 1] + in[x]); } int main() { int x; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d %d", &x, &in[i]); r[x].push_back(i); } for (int i = 1; i <= m; i++) dp[0][i] = -INF; f(0), printf("%d", dp[dp_lev][m]); }

Compilation message (stderr)

biochips.cpp: In function 'int main()':
biochips.cpp:23:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
biochips.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &in[i]);
                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...