#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
// Subtask 3
bool cmp(array<int, 3> a, array<int, 3> b)
{
if(a[1] != b[1]) return a[1] < b[1];
return a[0] > b[0];
}
long long max_weights(int N, int M, std::vector<int> X,
std::vector<int> Y, std::vector<int> W) {
vector<long long> vect(N, 0);
for(int i = 0; i < M; i++)
{
vect[X[i]] += W[i];
}
if(N == 2)
{
return max(vect[0], vect[1]);
}
vector<long long> dp(N, 0);
dp[0] = vect[0];
dp[1] = vect[1];
dp[2] = dp[0] + vect[2];
long long ans = max({vect[0], vect[1], dp[0] + vect[2]});
for(int i = 3; i < N; i++)
{
dp[i] = max(dp[i - 2], dp[i - 3]) + vect[i];
ans = max(ans, dp[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
3532 KB |
Output is correct |
2 |
Correct |
28 ms |
4156 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Correct |
91 ms |
8816 KB |
Output is correct |
6 |
Correct |
87 ms |
8780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
17 ms |
3000 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
17 ms |
3000 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
3532 KB |
Output is correct |
2 |
Correct |
28 ms |
4156 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Correct |
91 ms |
8816 KB |
Output is correct |
6 |
Correct |
87 ms |
8780 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |