Submission #1079002

# Submission time Handle Problem Language Result Execution time Memory
1079002 2024-08-28T09:16:27 Z LittleOrange Catfish Farm (IOI22_fish) C++17
18 / 100
129 ms 27728 KB
#include "fish.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll big = 1e18;

long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y,
                      std::vector<int> w) {
  ll sub1 = 1, sub2 = 1, sub3 = 1;
  n++;
  vector<vector<pair<ll,ll>>> a(n);
  vector<vector<ll>> b(n);
  for(ll i = 0;i<m;i++){
    a[x[i]].push_back({y[i],w[i]});
    if(x[i]) b[x[i]-1].push_back(y[i]);
    b[x[i]+1].push_back(y[i]);
    if(x[i]&1) sub1 = 0;
    if(x[i]>1) sub2 = 0;
    if(y[i]) sub3 = 0;
  }
  //cerr << sub1 << " " << sub2 << " " << sub3 << "\n";
  n--;
  for(auto &o : a) sort(o.begin(),o.end());
  for(auto &o : b) sort(o.begin(),o.end());
  if (sub1){
    ll ans = 0;
    for(ll i : w) ans += i;
    return ans;
  }
  if(sub2){
    ll a1 = 0, a2 = 0;
    vector<array<ll,3>> o;
    for(auto [p,v] : a[0]) a1+=v,o.push_back({p,1,v});
    for(auto [p,v] : a[1]) a2+=v,o.push_back({p,0,v});
    ll ans = max(a1,a2);
    if(n>2){
      sort(o.begin(),o.end());
      ll dp0 = 0, dp1 = 0;
      for(auto &u : o){
        if (u[1]){
          dp0 += u[2];
          dp1 = max(dp1,dp0);
        }else{
          dp1 += u[2];
        }
      }
      ans = max(ans,dp1);
    }
    return ans;
  }
  if (sub3){
    ll ans = 0;
    for(ll i : w) ans += i;
    vector<ll> dp(n+1,big);
    dp[0] = 0;
    for(ll i = 0;i<n;i++){
      ll cur = a[i].size()?a[i][0].second:0;
      dp[i+1] = min(dp[i+1],dp[i]+cur);
      if(i>=1)dp[i+1] = min(dp[i+1],dp[i-1]+cur);
      if(i>=3)dp[i+1] = min(dp[i+1],dp[i-2]+cur);
    }
    //for(ll i = 0;i<=n;i++) cerr << dp[i] << " \n"[i==n];
    ll de = min(dp.back(),dp.end()[-2]);
    return ans-de;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 9420 KB Output is correct
2 Correct 34 ms 10700 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 129 ms 24248 KB Output is correct
6 Correct 114 ms 27728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 92 ms 21240 KB Output is correct
3 Correct 104 ms 23596 KB Output is correct
4 Correct 32 ms 9440 KB Output is correct
5 Correct 43 ms 10680 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 388 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 39 ms 14140 KB Output is correct
13 Correct 52 ms 15872 KB Output is correct
14 Correct 38 ms 13068 KB Output is correct
15 Correct 46 ms 13756 KB Output is correct
16 Correct 37 ms 12856 KB Output is correct
17 Correct 38 ms 13884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 37 ms 10020 KB Output is correct
4 Correct 19 ms 9564 KB Output is correct
5 Correct 49 ms 15988 KB Output is correct
6 Correct 41 ms 15444 KB Output is correct
7 Correct 47 ms 15952 KB Output is correct
8 Correct 44 ms 15956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 344 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 344 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 2 ms 4952 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 37 ms 10020 KB Output is correct
4 Correct 19 ms 9564 KB Output is correct
5 Correct 49 ms 15988 KB Output is correct
6 Correct 41 ms 15444 KB Output is correct
7 Correct 47 ms 15952 KB Output is correct
8 Correct 44 ms 15956 KB Output is correct
9 Incorrect 53 ms 14928 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 28 ms 9420 KB Output is correct
2 Correct 34 ms 10700 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 129 ms 24248 KB Output is correct
6 Correct 114 ms 27728 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 92 ms 21240 KB Output is correct
9 Correct 104 ms 23596 KB Output is correct
10 Correct 32 ms 9440 KB Output is correct
11 Correct 43 ms 10680 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 388 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 4952 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 39 ms 14140 KB Output is correct
19 Correct 52 ms 15872 KB Output is correct
20 Correct 38 ms 13068 KB Output is correct
21 Correct 46 ms 13756 KB Output is correct
22 Correct 37 ms 12856 KB Output is correct
23 Correct 38 ms 13884 KB Output is correct
24 Correct 2 ms 4952 KB Output is correct
25 Correct 2 ms 5724 KB Output is correct
26 Correct 37 ms 10020 KB Output is correct
27 Correct 19 ms 9564 KB Output is correct
28 Correct 49 ms 15988 KB Output is correct
29 Correct 41 ms 15444 KB Output is correct
30 Correct 47 ms 15952 KB Output is correct
31 Correct 44 ms 15956 KB Output is correct
32 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
33 Halted 0 ms 0 KB -