#include<bits/stdc++.h>
using namespace std;
long long group1(vector <int> W)
{
long long sum = 0;
for(int i : W)
{
sum += i;
}
return sum;
}
long long group2(int N, int M, vector <int> X, vector <int> Y, vector <int> W)
{
long long pref[2][N], cord = -1, mx = 0;
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < N; j++)
{
pref[i][j] = 0;;
}
}
for(int i = 0; i < M; i++)
{
pref[X[i]][Y[i]] = W[i];
}
for(int i = 0; i < 2; i++)
{
for(int j = 1; j < N; j++)
{
pref[i][j] += pref[i][j - 1];
}
}
for(int i = 0; i < N; i++)
{
if(pref[0][i] - pref[1][i] > mx)
{
mx = pref[0][i] - pref[1][i];
cord = i;
}
}
long long sum = pref[1][N - 1];
if(cord >= 0)
{
sum = sum - pref[1][cord] + pref[0][cord];
}
if(N == 2)
{
sum = max(pref[0][1], pref[1][1]);
}
return sum;
}
long long group3(int N, int M, vector <int> X, vector <int> Y, vector <int> W)
{
long long dp[2][N], a[N];
for(int i = 0; i < N; i++)
{
dp[0][i] = 0;
dp[1][i] = 0;
a[i] = 0;
}
for(int i = 0; i < M; i++)
{
a[X[i]] = W[i];
}
for(int i = 1; i < N; i++)
{
if(i > 1)
{
dp[1][i] = max(max(dp[0][i - 2] + a[i - 1], dp[1][i - 2] + a[i - 1]), dp[1][i - 1]);
}
else
{
dp[1][i] = dp[0][i - 1] + a[i - 1];
}
dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + a[i]);
}
if(N > 1)
{
return max(max(dp[0][N - 1], dp[1][N - 1]), max(dp[0][N - 2], dp[1][N - 2]));
}
else
{
return max(dp[0][N - 1], dp[1][N - 1]);
}
}
long long group4()
{
}
long long group5()
{
}
long long group6()
{
}
long long group7()
{
}
long long full()
{
}
long long max_weights(int N, int M, vector <int> X, vector <int> Y, vector <int> W)
{
bool flag1 = true;
bool flag2 = true;
bool flag3 = true;
bool flag4 = true;
for(int i = 0; i < M; i++)
{
if(X[i] % 2 != 0)
{
flag1 = false;
}
if(X[i] > 1)
{
flag2 = false;
}
if(Y[i] != 0)
{
flag3 = false;
}
if(Y[i] > 8)
{
flag4 = false;
}
}
//cout << flag1 << " " << flag2 << " " << flag3 << " " << flag4 << endl;
if(flag1)
{
return group1(W);
}
if(flag2)
{
return group2(N, M, X, Y, W);
}
if(flag3)
{
return group3(N, M, X, Y, W);
}
if(flag4)
{
return group4();
}
return 0;
}
/**
int main()
{
ios_base::sync_with_stdio(false);
cout << max_weights(3, 3, {0, 1, 2}, {0, 0, 0}, {1, 1, 1});
}
/**/
Compilation message
fish.cpp:161:1: warning: "/*" within comment [-Wcomment]
161 | /**/
|
fish.cpp: In function 'long long int group4()':
fish.cpp:93:1: warning: no return statement in function returning non-void [-Wreturn-type]
93 | }
| ^
fish.cpp: In function 'long long int group5()':
fish.cpp:97:1: warning: no return statement in function returning non-void [-Wreturn-type]
97 | }
| ^
fish.cpp: In function 'long long int group6()':
fish.cpp:101:1: warning: no return statement in function returning non-void [-Wreturn-type]
101 | }
| ^
fish.cpp: In function 'long long int group7()':
fish.cpp:105:1: warning: no return statement in function returning non-void [-Wreturn-type]
105 | }
| ^
fish.cpp: In function 'long long int full()':
fish.cpp:109:1: warning: no return statement in function returning non-void [-Wreturn-type]
109 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3928 KB |
Output is correct |
2 |
Correct |
15 ms |
4696 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
48 ms |
14936 KB |
Output is correct |
6 |
Correct |
53 ms |
15196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
31 ms |
10272 KB |
Output is correct |
3 |
Correct |
39 ms |
12508 KB |
Output is correct |
4 |
Correct |
12 ms |
3932 KB |
Output is correct |
5 |
Correct |
16 ms |
4680 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
360 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
436 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
6128 KB |
Output is correct |
13 |
Correct |
16 ms |
7260 KB |
Output is correct |
14 |
Correct |
14 ms |
6236 KB |
Output is correct |
15 |
Correct |
15 ms |
6744 KB |
Output is correct |
16 |
Correct |
13 ms |
5980 KB |
Output is correct |
17 |
Correct |
15 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2736 KB |
Output is correct |
3 |
Correct |
9 ms |
5288 KB |
Output is correct |
4 |
Correct |
10 ms |
4700 KB |
Output is correct |
5 |
Correct |
17 ms |
7772 KB |
Output is correct |
6 |
Correct |
14 ms |
7256 KB |
Output is correct |
7 |
Correct |
19 ms |
7772 KB |
Output is correct |
8 |
Correct |
19 ms |
7772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2736 KB |
Output is correct |
3 |
Correct |
9 ms |
5288 KB |
Output is correct |
4 |
Correct |
10 ms |
4700 KB |
Output is correct |
5 |
Correct |
17 ms |
7772 KB |
Output is correct |
6 |
Correct |
14 ms |
7256 KB |
Output is correct |
7 |
Correct |
19 ms |
7772 KB |
Output is correct |
8 |
Correct |
19 ms |
7772 KB |
Output is correct |
9 |
Incorrect |
15 ms |
3928 KB |
1st lines differ - on the 1st token, expected: '99999', found: '0' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3928 KB |
Output is correct |
2 |
Correct |
15 ms |
4696 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
48 ms |
14936 KB |
Output is correct |
6 |
Correct |
53 ms |
15196 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
31 ms |
10272 KB |
Output is correct |
9 |
Correct |
39 ms |
12508 KB |
Output is correct |
10 |
Correct |
12 ms |
3932 KB |
Output is correct |
11 |
Correct |
16 ms |
4680 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
360 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
436 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
14 ms |
6128 KB |
Output is correct |
19 |
Correct |
16 ms |
7260 KB |
Output is correct |
20 |
Correct |
14 ms |
6236 KB |
Output is correct |
21 |
Correct |
15 ms |
6744 KB |
Output is correct |
22 |
Correct |
13 ms |
5980 KB |
Output is correct |
23 |
Correct |
15 ms |
6492 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
2736 KB |
Output is correct |
26 |
Correct |
9 ms |
5288 KB |
Output is correct |
27 |
Correct |
10 ms |
4700 KB |
Output is correct |
28 |
Correct |
17 ms |
7772 KB |
Output is correct |
29 |
Correct |
14 ms |
7256 KB |
Output is correct |
30 |
Correct |
19 ms |
7772 KB |
Output is correct |
31 |
Correct |
19 ms |
7772 KB |
Output is correct |
32 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
33 |
Halted |
0 ms |
0 KB |
- |