Submission #1319283

#TimeUsernameProblemLanguageResultExecution timeMemory
1319283nathlol2Topical (NOI23_topical)C++20
28 / 100
2 ms568 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 105;
int n, m, ans, r[N][N], u[N][N], a[N], v[N];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i = 1;i<=n;i++) for(int j = 1;j<=m;j++) cin >> r[i][j];
    for(int i = 1;i<=n;i++) for(int j = 1;j<=m;j++) cin >> u[i][j];
    while(1){
        bool f = 0;
        for(int i = 1;i<=n;i++){
            if(v[i]) continue;
            bool ff = 1;
            for(int j = 1;j<=m;j++){
                if(a[j] < r[i][j]){
                    ff = 0;
                }
            }
            if(ff){
                f = 1;
                for(int j = 1;j<=m;j++){
                    a[j] += u[i][j];
                }
                v[i] = 1;
                break;
            }
        }
        if(!f) break;
        ++ans;
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...