제출 #1329156

#제출 시각아이디문제언어결과실행 시간메모리
1329156thanhsonTopical (NOI23_topical)C++20
28 / 100
2 ms4420 KiB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;

mt19937_64 rng(time(NULL));

ll rand(ll l, ll r) {
  return rng() % (r - l + 1) + l;
}

ll power(ll a, ll b) {
  if (b == 0) return 1;
  ll ans = power(a, b / 2);
  ans *= ans;
  if (b % 2 == 1) ans *= a;
  return ans;
}

const ll N = 1e3 + 5;
ll n, k, p[N], r[N][N], u[N][N], cnt[N];

void solve() {
    cin >> n >> k;
    for (int i = 0; i < k; i ++) p[i] = 0;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < k; j ++) {
            cin >> r[i][j];
        }
    }
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < k; j ++) {
            cin >> u[i][j];
        }
    }
    ll t = 0;
    bool nig = true;
    while (nig == true) {
        nig = false;
        for (int i = 0; i < n; i ++) if (cnt[i] == 0) {
            bool ok = true;
            for (int j = 0; j < k; j ++) {
                if (p[j] < r[i][j]) {
                    ok = false;
                    break;
                }
            }
            if (ok == true) {
                for (int j = 0; j < k; j ++) {
                    p[j] += u[i][j];
                }
                t ++;
                cnt[i] ++;
                nig = true;
            }
        }
    }
    cout << t;
}

int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll query = 1;
  // cin >> query;
  while (query --) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...