답안 #893328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893328 2023-12-27T02:06:25 Z vjudge1 Topical (NOI23_topical) C++17
100 / 100
405 ms 174080 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)

const int maxn = 1e6+5;
int n, m, cnt[maxn], p[maxn];
vector<int> a[maxn], u[maxn];
vector<pair<int, int>> val[maxn];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    fileio("");
    // freopen("debug.txt", "w", stderr);

    cin >> n >> m;
    for (int i = 0; i <= n+1; i++) {
        a[i] = vector<int>(m+2, 0);
        u[i] = vector<int>(m+2, 0);
    }

    vector<int> cur;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if (a[i][j] == 0) {
                cnt[i]++;
            }
            val[j].push_back({a[i][j], i});
        }
        if (cnt[i] == m) {
            cur.push_back(i);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> u[i][j];
        }
    }
    for (int j = 1; j <= m; j++) {
        sort(val[j].rbegin(), val[j].rend());
        while (!val[j].empty() && val[j].back().first == 0) {
            val[j].pop_back();
        }
    }

    int res = 0;
    while (!cur.empty()) {
        int i = cur.back(); cur.pop_back();
        res++;

        for (int j = 1; j <= m; j++) {
            p[j] += u[i][j];
            while (!val[j].empty() && val[j].back().first <= p[j]) {
                int x = val[j].back().second;
                val[j].pop_back();
                if (++cnt[x] == m) {
                    cur.push_back(x);
                }
            }
        }
    }
    cout << res;

    return 0 ^ 0;
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:5:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:15:5: note: in expansion of macro 'fileio'
   15 |     fileio("");
      |     ^~~~~~
Main.cpp:5:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:15:5: note: in expansion of macro 'fileio'
   15 |     fileio("");
      |     ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 72280 KB Output is correct
2 Correct 15 ms 74332 KB Output is correct
3 Correct 18 ms 75208 KB Output is correct
4 Correct 198 ms 164948 KB Output is correct
5 Correct 195 ms 165088 KB Output is correct
6 Correct 196 ms 165108 KB Output is correct
7 Correct 162 ms 153684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 74332 KB Output is correct
2 Correct 15 ms 74512 KB Output is correct
3 Correct 15 ms 72284 KB Output is correct
4 Correct 15 ms 72284 KB Output is correct
5 Correct 17 ms 74332 KB Output is correct
6 Correct 16 ms 72284 KB Output is correct
7 Correct 18 ms 72796 KB Output is correct
8 Correct 18 ms 73016 KB Output is correct
9 Correct 17 ms 74844 KB Output is correct
10 Correct 18 ms 72796 KB Output is correct
11 Correct 18 ms 72796 KB Output is correct
12 Correct 19 ms 72796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 72280 KB Output is correct
2 Correct 15 ms 72284 KB Output is correct
3 Correct 20 ms 73808 KB Output is correct
4 Correct 52 ms 82116 KB Output is correct
5 Correct 46 ms 81856 KB Output is correct
6 Correct 405 ms 174080 KB Output is correct
7 Correct 354 ms 165544 KB Output is correct
8 Correct 399 ms 173776 KB Output is correct
9 Correct 354 ms 166316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 72280 KB Output is correct
2 Correct 15 ms 74332 KB Output is correct
3 Correct 18 ms 75208 KB Output is correct
4 Correct 198 ms 164948 KB Output is correct
5 Correct 195 ms 165088 KB Output is correct
6 Correct 196 ms 165108 KB Output is correct
7 Correct 162 ms 153684 KB Output is correct
8 Correct 16 ms 74332 KB Output is correct
9 Correct 15 ms 74512 KB Output is correct
10 Correct 15 ms 72284 KB Output is correct
11 Correct 15 ms 72284 KB Output is correct
12 Correct 17 ms 74332 KB Output is correct
13 Correct 16 ms 72284 KB Output is correct
14 Correct 18 ms 72796 KB Output is correct
15 Correct 18 ms 73016 KB Output is correct
16 Correct 17 ms 74844 KB Output is correct
17 Correct 18 ms 72796 KB Output is correct
18 Correct 18 ms 72796 KB Output is correct
19 Correct 19 ms 72796 KB Output is correct
20 Correct 15 ms 72280 KB Output is correct
21 Correct 15 ms 72284 KB Output is correct
22 Correct 20 ms 73808 KB Output is correct
23 Correct 52 ms 82116 KB Output is correct
24 Correct 46 ms 81856 KB Output is correct
25 Correct 405 ms 174080 KB Output is correct
26 Correct 354 ms 165544 KB Output is correct
27 Correct 399 ms 173776 KB Output is correct
28 Correct 354 ms 166316 KB Output is correct
29 Correct 236 ms 118152 KB Output is correct
30 Correct 238 ms 113360 KB Output is correct
31 Correct 276 ms 118720 KB Output is correct
32 Correct 188 ms 115536 KB Output is correct
33 Correct 197 ms 109652 KB Output is correct
34 Correct 229 ms 112528 KB Output is correct
35 Correct 263 ms 117328 KB Output is correct
36 Correct 221 ms 114184 KB Output is correct
37 Correct 243 ms 115652 KB Output is correct
38 Correct 185 ms 115728 KB Output is correct