Submission #836813

# Submission time Handle Problem Language Result Execution time Memory
836813 2023-08-24T16:03:06 Z Supersonic Catfish Farm (IOI22_fish) C++17
18 / 100
73 ms 12864 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y,
                      std::vector<int> w) {
  bool s1=1,s2=1,s3=1;
  for(auto i:x){if(i%2==1)s1=0;if(i>=2)s2=0;}
  for(auto i:y)if(i>0)s3=0;
  if(s1){
    long long t=0;
    for(auto i:w)t+=i;
    return t;
  }
  vector<pair<int,int>> a[n];
  int sa0[n];int sa1[n];
  for(int i=0;i<n;i++)sa0[i]=sa1[i]=0;
  for(int i=0;i<m;i++){
    a[x[i]].push_back({y[i],w[i]});
    if(x[i]==0)sa0[y[i]]=w[i];
    if(x[i]==1)sa1[y[i]]=w[i];
  }
  if(s2){
    if(n==2){
      long long at=0,bt=0;
      for(auto i:a[0])at+=i.second;
      for(auto i:a[1])bt+=i.second;
      return max(at,bt);
    }
    long long t=0;
    for(auto i:a[1])t+=i.second;
    long long ai=0,bi=t;
    for(int i=0;i<n;i++){
      ai+=sa0[i];bi-=sa1[i];
      t=max(t,ai+bi);
    }
    return t;
  }
  if(s3){
    ll aa[n];
    for(int i=0;i<n;i++)aa[i]=0;
    for(int i=0;i<m;i++){aa[x[i]]=w[i];}

    ll dp[n][2];
    dp[0][0]=0;dp[0][1]=0;
    dp[1][0]=aa[1];dp[1][1]=aa[0];
    for(int i=2;i<n;i++){dp[i][0]=max(dp[i-1][0],dp[i-1][1]+aa[i]);dp[i][1]=max({dp[i-1][1],dp[i-1][0],dp[i-2][0]+aa[i-1]});}
    return max(dp[n-1][0],dp[n-1][1]);
  }
  return 0;
}
/*
5 4
0 0 5
1 0 2
4 0 1
3 0 3



*/
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2132 KB Output is correct
2 Correct 23 ms 2636 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 72 ms 7264 KB Output is correct
6 Correct 73 ms 7264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 42 ms 8552 KB Output is correct
3 Correct 49 ms 9896 KB Output is correct
4 Correct 18 ms 2156 KB Output is correct
5 Correct 25 ms 2640 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 20 ms 6092 KB Output is correct
13 Correct 25 ms 6860 KB Output is correct
14 Correct 22 ms 5864 KB Output is correct
15 Correct 23 ms 6480 KB Output is correct
16 Correct 20 ms 5968 KB Output is correct
17 Correct 23 ms 6468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 3 ms 5716 KB Output is correct
3 Correct 21 ms 8148 KB Output is correct
4 Correct 15 ms 8276 KB Output is correct
5 Correct 33 ms 12864 KB Output is correct
6 Correct 29 ms 12108 KB Output is correct
7 Correct 38 ms 12752 KB Output is correct
8 Correct 32 ms 12748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 3 ms 5716 KB Output is correct
3 Correct 21 ms 8148 KB Output is correct
4 Correct 15 ms 8276 KB Output is correct
5 Correct 33 ms 12864 KB Output is correct
6 Correct 29 ms 12108 KB Output is correct
7 Correct 38 ms 12752 KB Output is correct
8 Correct 32 ms 12748 KB Output is correct
9 Incorrect 29 ms 10320 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2132 KB Output is correct
2 Correct 23 ms 2636 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 72 ms 7264 KB Output is correct
6 Correct 73 ms 7264 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 42 ms 8552 KB Output is correct
9 Correct 49 ms 9896 KB Output is correct
10 Correct 18 ms 2156 KB Output is correct
11 Correct 25 ms 2640 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 20 ms 6092 KB Output is correct
19 Correct 25 ms 6860 KB Output is correct
20 Correct 22 ms 5864 KB Output is correct
21 Correct 23 ms 6480 KB Output is correct
22 Correct 20 ms 5968 KB Output is correct
23 Correct 23 ms 6468 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 3 ms 5716 KB Output is correct
26 Correct 21 ms 8148 KB Output is correct
27 Correct 15 ms 8276 KB Output is correct
28 Correct 33 ms 12864 KB Output is correct
29 Correct 29 ms 12108 KB Output is correct
30 Correct 38 ms 12752 KB Output is correct
31 Correct 32 ms 12748 KB Output is correct
32 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
33 Halted 0 ms 0 KB -