# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720544 |
2023-04-08T12:34:57 Z |
lam |
Catfish Farm (IOI22_fish) |
C++17 |
|
52 ms |
8760 KB |
#include "fish.h"
#include <vector>
#define ll long long
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 3e5 + 10;
int n,m;
ii a[maxn]; int w[maxn];
bool cmp(int x, int y)
{
return a[x]<a[y];
}
ll sub3()
{
vector <ll> b(n,0);
for (int i=0; i<m; i++)
b[a[i].ff] += w[i];
vector <ll> dp[3];
for (int i=0; i<3; i++) dp[i].assign(n,0);
dp[1][0] = b[0];
for (int i=0; i+1<n; i++)
{
for (int j=0; j<3; j++)
{
if (j==1) dp[2][i+1] = max(dp[2][i+1],dp[j][i]+b[i+1]);
else dp[0][i+1] = max(dp[0][i+1],dp[j][i]);
int val=0;
if (j==0) val+=b[i];
dp[1][i+1] = max(dp[1][i+1],dp[j][i]+val);
}
}
int ans=max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
return ans;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
n=N; m=M;
for (int i=0; i<m; i++) a[i]={X[i],Y[i]}, w[i]=W[i];
return sub3();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
5968 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '709728670' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
52 ms |
8760 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '1040403569' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3412 KB |
Output is correct |
2 |
Correct |
4 ms |
3412 KB |
Output is correct |
3 |
Incorrect |
21 ms |
5916 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '1869041008' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '7', found: '5' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3412 KB |
Output is correct |
2 |
Correct |
4 ms |
3412 KB |
Output is correct |
3 |
Incorrect |
21 ms |
5916 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '1869041008' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
5968 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '709728670' |
2 |
Halted |
0 ms |
0 KB |
- |