Submission #1328721

#TimeUsernameProblemLanguageResultExecution timeMemory
1328721NaaTopical (NOI23_topical)C++20
40 / 100
1096 ms23932 KiB
#include <bits/stdc++.h>
using namespace std;
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

using i32 = long long;

#define all(a) (a).begin(), (a).end()
#define open(x) if(fopen(#x ".inp", "r")) {freopen(#x ".inp", "r", stdin); freopen(#x ".out", "w", stdout);}

template<class X, class Y> bool mimi(X &x, const Y &y) {if(x > y) {x = y; return 1;} return 0;}
template<class X, class Y> bool mama(X &x, const Y &y) {if(x < y) {x = y; return 1;} return 0;}

const i32 N = 1e6 + 5;
const i32 M = 1000000007;
const i32 inf = 1000000009;
const i32 infll = (i32)1000000000000000018;

vector<i32> r[N], u[N];

void sad(i32 testID) {
    i32 n, k; 
    cin >> n >> k;

    vector<vector<i32>> r(n, vector<i32>(k)), u(n, vector<i32>(k));

    for(i32 i = 0; i < n; i ++)
        for(i32 j = 0; j < k; j ++)
            cin >> r[i][j];

    for(i32 i = 0; i < n; i ++)
        for(i32 j = 0; j < k; j ++)
            cin >> u[i][j];

    vector<i32> p(k, 0);
    vector<bool> in(n, false);
    i32 res = 0;

    bool check = true;

    while(check) {
        check = false;
        for(i32 i = 0; i < n; i ++) {
            if(in[i]) continue;

            bool ok = true;
            for(i32 j = 0; j < k; j ++) if(p[j] < r[i][j]) {
                ok = false;
                break;
            }
            if(ok) {
                in[i] = true; res ++;
                check = true;
                for(i32 j = 0; j < k; j ++) p[j] += u[i][j];
            }
        }
    }

    cout << res << endl;
}

signed main() {
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    open(task)

    i32 t = 1;
    // cin >> t;
    for(i32 testID = 1; testID <= t; testID++) {
        // cout << "Case #" << testID << ":\n";
        sad(testID);
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    // cerr << endl << "Time measured: " << elapsed.count() * 1e-9 << " seconds." << endl; 
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:51: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define open(x) if(fopen(#x ".inp", "r")) {freopen(#x ".inp", "r", stdin); freopen(#x ".out", "w", stdout);}
      |                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:5: note: in expansion of macro 'open'
   66 |     open(task)
      |     ^~~~
Main.cpp:8:83: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define open(x) if(fopen(#x ".inp", "r")) {freopen(#x ".inp", "r", stdin); freopen(#x ".out", "w", stdout);}
      |                                                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:5: note: in expansion of macro 'open'
   66 |     open(task)
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...