Submission #73769769


Source Code Expand

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;
#define REP(i,n) for(ll i=0; i<ll(n); i++)
template <class T> using V = vector<T>;
template <class A, class B> void chmax(A& l, const B& r){ if(l < r) l = r; }
template <class A, class B> void chmin(A& l, const B& r){ if(r < l) l = r; }


void testcase(){
  ll N; cin >> N;
  V<ll> Q(N), A(N), B(N);
  REP(i,N) cin >> Q[i];
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
  ll bound = INF;
  REP(i,N) if(A[i]) chmin(bound, Q[i] / A[i]);
  ll ans = bound;
  for(ll a=0; a<=bound; a++){
    ll b = INF;
    REP(i,N){
      if(B[i]) chmin(b, (Q[i] - A[i] * a) / B[i]);
    }
    chmax(ans, a + b);
  }
  cout << ans << "\n";
}

int main(){
  cin.tie(0)->sync_with_stdio(0);
  testcase();
  return 0;
}

Submission Info

Submission Time
Task F - Leftover Recipes
User Nachia
Language C++23 (GCC 15.2.0)
Score 300
Code Size 874 Byte
Status AC
Exec Time 7 ms
Memory 3600 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 18
Set Name Test Cases
Sample 01-sample.txt, 02-sample.txt, 03-sample.txt, 04-sample.txt
All 01-sample.txt, 02-sample.txt, 03-sample.txt, 04-sample.txt, 05-hidden.txt, 06-hidden.txt, 07-hidden.txt, 08-hidden.txt, 09-hidden.txt, 10-hidden.txt, 11-hidden.txt, 12-hidden.txt, 13-hidden.txt, 14-hidden.txt, 15-hidden.txt, 16-hidden.txt, 17-hidden.txt, 18-hidden.txt
Case Name Status Exec Time Memory
01-sample.txt AC 1 ms 3460 KiB
02-sample.txt AC 1 ms 3536 KiB
03-sample.txt AC 1 ms 3532 KiB
04-sample.txt AC 4 ms 3524 KiB
05-hidden.txt AC 1 ms 3600 KiB
06-hidden.txt AC 1 ms 3476 KiB
07-hidden.txt AC 4 ms 3532 KiB
08-hidden.txt AC 4 ms 3524 KiB
09-hidden.txt AC 7 ms 3600 KiB
10-hidden.txt AC 5 ms 3524 KiB
11-hidden.txt AC 2 ms 3484 KiB
12-hidden.txt AC 2 ms 3536 KiB
13-hidden.txt AC 2 ms 3468 KiB
14-hidden.txt AC 2 ms 3468 KiB
15-hidden.txt AC 1 ms 3524 KiB
16-hidden.txt AC 4 ms 3536 KiB
17-hidden.txt AC 1 ms 3544 KiB
18-hidden.txt AC 1 ms 3552 KiB