Submission #901710

# Submission time Handle Problem Language Result Execution time Memory
901710 2024-01-10T01:14:32 Z iliccmarko Catfish Farm (IOI22_fish) C++17
3 / 100
159 ms 33908 KB
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 10000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL

ll levoo(int i, vector<ll> &levo, int n) {
    if (i < 0 || i >= n)
        return 0;
    return levo[i];
}

ll desnoo(int i, vector<ll> &desno, int n) {
    if (i < 0 || i >= n)
        return 0;
    return desno[i];
}

ll dpp(int i, int j, vector<vector<ll> > &dp, int n) {
    if (i < 0 || i >= n)
        return 0;
    return dp[i][j];
}

ll vall(int i, vector<ll> &val, int n) {
    if (i < 0 || i >= n)
        return 0;
    return val[i];
}

long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
  vector<ll> val(n, 0);
  vector<set<ll> > visine(n);
  vector<ll> desno(n, 0), levo(n, 0);

  for (int i = 0; i < m; ++i) {
    visine[x[i]].insert(i);
    val[x[i]] += (ll)w[i];
  }

  ll sigurno = 0;
  for (int i = 0; i < n; ++i) {
    ll cnt = 0;
    if (i - 1 >= 0) {
        for (ll ind : visine[i]) {
            if (y[ind] >= *visine[i - 1].begin())
                break;
            cnt += (ll)w[ind];
            levo[i] = cnt;
        }
    }
    if (i + 1 < n) {
        cnt = 0;
        for (ll ind : visine[i]) {
            if (y[ind] >= *visine[i + 1].begin())
                break;
            cnt += (ll)w[ind];
            desno[i] = cnt;
        }
    }
  }

  vector<vector<ll> > dp(n, vector<ll>(2, 0));
  for (int i = 0; i < n; ++i) {
        dp[i][0] = max(vall(i - 1, val, n) + max({dpp(i - 2, 0, dp, n), desnoo(i - 2, desno, n) + max({dpp(i - 3, 0, dp, n), dpp(i - 3, 1, dp, n)})}), dpp(i - 2, 1, dp, n));
        dp[i][1] = ((i - 1 >= 0) ? val[i] : 0LL) + max(dpp(i - 2, 0, dp, n), dpp(i - 2, 1, dp, n));
  }
  ll jos = 0;
  if (n >= 2) {
    jos = dp[n - 2][1] + levo[n - 1];
  }

  return max({dp[n - 1][0], dp[n - 1][1], jos});

}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:51:6: warning: unused variable 'sigurno' [-Wunused-variable]
   51 |   ll sigurno = 0;
      |      ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 37 ms 17144 KB Output is correct
2 Correct 46 ms 19792 KB Output is correct
3 Correct 8 ms 12892 KB Output is correct
4 Correct 8 ms 12888 KB Output is correct
5 Correct 129 ms 33908 KB Output is correct
6 Correct 159 ms 33908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 65 ms 23120 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40479197388443'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12892 KB Output is correct
2 Correct 8 ms 12892 KB Output is correct
3 Incorrect 25 ms 15416 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21889548692729'
4 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: '2'
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: '2'
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: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12892 KB Output is correct
2 Correct 8 ms 12892 KB Output is correct
3 Incorrect 25 ms 15416 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '21889548692729'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 17144 KB Output is correct
2 Correct 46 ms 19792 KB Output is correct
3 Correct 8 ms 12892 KB Output is correct
4 Correct 8 ms 12888 KB Output is correct
5 Correct 129 ms 33908 KB Output is correct
6 Correct 159 ms 33908 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 65 ms 23120 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40479197388443'
9 Halted 0 ms 0 KB -