Submission #1078907

# Submission time Handle Problem Language Result Execution time Memory
1078907 2024-08-28T07:58:25 Z LittleOrange Catfish Farm (IOI22_fish) C++17
3 / 100
125 ms 33112 KB
#include "fish.h"

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

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;
  }
  for(auto &o : a) sort(o.begin(),o.end());
  for(auto &o : b) sort(o.begin(),o.end());
  if(sub2&&n>2) sub1 = 1;
  if (sub1){
    ll ans = 0;
    for(ll i : w) ans += i;
    return ans;
  }
  if(sub2){
    ll a1 = 0, a2 = 0;
    for(auto [p,v] : a[0]) a1+=v;
    for(auto [p,v] : a[1]) a2+=v;
    return max(a1,a2);
  }
  if (sub3){
    vector<ll> dp(n+1,0);
    for(ll i = 0;i<n;i++){
      dp[i+1] = dp[i];
      if(a[i].size()){
        ll v = a[i][0].second;
        if (i>0) v += a[i-1][0].second;;
        if (i>=3) v += dp[i-3];
        dp[i+1] = max(dp[i+1],v);
      }
    }
    return dp.back();
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 29 ms 10952 KB Output is correct
2 Correct 39 ms 12368 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 120 ms 29160 KB Output is correct
6 Correct 125 ms 33112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 77 ms 16588 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Runtime error 7 ms 11612 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 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 1 ms 348 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 1 ms 348 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 3 ms 4956 KB Output is correct
2 Runtime error 7 ms 11612 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 10952 KB Output is correct
2 Correct 39 ms 12368 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 120 ms 29160 KB Output is correct
6 Correct 125 ms 33112 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 77 ms 16588 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025'
9 Halted 0 ms 0 KB -