#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pi 3.14159265359
#define pub push_back
#define pob pop_back
//#include <fish.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w)
{
ll cnt[n];
for(int i=0; i<n; i++) {
cnt[i] = 0;
}
for(int i=0; i<m; i++) {
cnt[x[i]] += w[i]; //cout<<cnt[x[i]]<<endl;
}
ll dp[n+1];
dp[n] = 0;
dp[n-1] = cnt[n-1];
for(int i=n-2; i>=0; i--) {
dp[i] = dp[i+2] + cnt[i];
dp[i] = max(dp[i], dp[i+1]);
for(int j=i+2; j<=min(n, i+5); j++) {
if(j>=n-1) {
dp[i] = max(dp[i], cnt[j-1]);
} else
{
dp[i] = max(dp[i], cnt[j-1] + dp[j+1]);
}
}
}
return dp[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
3540 KB |
Output is correct |
2 |
Correct |
32 ms |
5632 KB |
Output is correct |
3 |
Correct |
3 ms |
1748 KB |
Output is correct |
4 |
Correct |
2 ms |
1748 KB |
Output is correct |
5 |
Correct |
99 ms |
10856 KB |
Output is correct |
6 |
Correct |
100 ms |
11084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1748 KB |
Output is correct |
2 |
Correct |
2 ms |
1852 KB |
Output is correct |
3 |
Incorrect |
19 ms |
3532 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 |
3 ms |
1748 KB |
Output is correct |
2 |
Correct |
2 ms |
1852 KB |
Output is correct |
3 |
Incorrect |
19 ms |
3532 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
3540 KB |
Output is correct |
2 |
Correct |
32 ms |
5632 KB |
Output is correct |
3 |
Correct |
3 ms |
1748 KB |
Output is correct |
4 |
Correct |
2 ms |
1748 KB |
Output is correct |
5 |
Correct |
99 ms |
10856 KB |
Output is correct |
6 |
Correct |
100 ms |
11084 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |