Submission #1334140

#TimeUsernameProblemLanguageResultExecution timeMemory
1334140viettrungTopical (NOI23_topical)C++20
100 / 100
305 ms78696 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fi first
#define se second
#define mll map<ll, ll>
#define sll set<ll>
const ll du = 1e9 + 7;
const ll ars = 1e6 + 5;

int n, k;
vector<ll> a[ars];
int cs[ars];
vector<pll> lis[ars];
ll cur[ars], f[ars];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "tenshi"
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin >> n >> k;
    for(int i = 0; i < k; i++)
        lis[i].assign(n, {0, 0});

    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> lis[j][i].fi;
            lis[j][i].se = i;
        }
    }
    for(int j = 0; j < k; j++)
        sort(lis[j].begin(), lis[j].end());

    for(int i = 0; i < n; i++){
        a[i].assign(k, 0);
        for(int j = 0; j < k; j++)
            cin >> a[i][j];
    }

    int ans = 0;
    bool ok = true;
    while(ok){
        ok = false;
        for(int j = 0; j < k; j++){
            while(cs[j] < lis[j].size() && lis[j][cs[j]].fi <= cur[j]){
                ok = true;
                auto[val, id] = lis[j][cs[j]];
                cs[j]++;
                f[id]++;
                if(f[id] == k){
                    ans++;
                    for(int j2 = 0; j2 < k; j2++)
                        cur[j2] += a[id][j2];
                }
            }
        }
    }
    cout << ans;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...