Submission #756067

#TimeUsernameProblemLanguageResultExecution timeMemory
756067yeysoCatfish Farm (IOI22_fish)C++17
9 / 100
49 ms15912 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #include <vector> /* N - rows and columns M - number of fish X, Y - coordinates W - weights Y[i] = 0 means that we can only harvest up to 3 fish at a time */ long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { /*long long subtask1 = 1; long long subtask2 = 1; long long subtask3 = 1; long long res = 0; for(long long i = 0; i < W.size(); i ++){ if(X[i] % 2 == 0){ res += W[i]; } else { subtask1 = 0; } if(Y[i] > 1){ subtask2 = 0; } }*/ vector<vector<long long>> fish(M, vector<long long>()); for(long long i = 0; i < M; i ++){ fish[i] = {X[i], Y[i], W[i]}; } vector<long long> p(N, 0); for(long long i = 0; i < M; i ++){ p[X[i]] = W[i]; } vector<vector<long long>> dp(N+1, vector<long long>(3, 0)); dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = p[0]; for(long long i = 1; i < p.size(); i ++){ dp[i][1] = dp[i-1][0]+p[i]; dp[i][2] = max(dp[i-1][0], dp[i-1][1])+p[i]; dp[i][0] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2])); } /*for(long long i = 0; i < dp.size(); i ++){ cout << dp[i][0] << " "; }*/ return max(dp[N-1][1], dp[N-1][0]); //sort(fish.begin(), fish.end()); } /* g++ -std=gnu++17 -O2 -Wall -pipe -static -o fish grader.cpp fish.cpp 6 6 0 0 4 1 0 2 2 0 3 3 0 1 4 0 5 5 0 3 4 2 3 1 5 3 */

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:41:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(long long i = 1; i < p.size(); i ++){
      |                          ~~^~~~~~~~~~
#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...