Submission #652466

#TimeUsernameProblemLanguageResultExecution timeMemory
652466BlagojCatfish Farm (IOI22_fish)C++17
9 / 100
88 ms7264 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { bool Even = true, Less = true; long long sum1 = 0, sum2 = 0; for (auto x : X) { if (x % 2 != 0) { Even = false; } if (x > 1) { Less = false; } } if (Even) { long long sum = 0; for (auto x : W) { sum += x; } return sum; } if (Less) { long long m[N + 3][3]; memset(m, 0, sizeof(m)); for (int i = 0; i < M; i++) { m[Y[i]][X[i]] = W[i]; } for (int i = 1; i < N; i++) { m[i][0] += m[i - 1][0]; m[i][1] += m[i - 1][1]; } long long ans = max(m[N - 1][0], m[N - 1][1]); if (N == 2) { return ans; } for (int i = 0; i < N; i++) { ans = max(ans, m[i][0] + m[N - 1][1] - m[i][1]); } return ans; } long long dp[N + 3], p[N + 3]; memset(dp, 0, sizeof(dp)); memset(p, 0, sizeof(p)); for (int i = 0; i < M; i++) { p[X[i]] = W[i]; } dp[0] = p[0]; dp[1] = max(p[0], p[1]); for (int i = 2; i < N; i++) { dp[i] = max(dp[i - 2] + p[i], dp[i - 1]); } return dp[N - 1]; }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:9:13: warning: unused variable 'sum1' [-Wunused-variable]
    9 |   long long sum1 = 0, sum2 = 0;
      |             ^~~~
fish.cpp:9:23: warning: unused variable 'sum2' [-Wunused-variable]
    9 |   long long sum1 = 0, sum2 = 0;
      |                       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...