답안 #1102255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102255 2024-10-18T01:03:49 Z thangdz2k7 Topical (NOI23_topical) C++17
100 / 100
484 ms 109512 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 1e6 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

int n, k, p[N], can[N], id[N];
vector <pair <int, int>> r[N];
vector <int> u[N];

void solve(){
    cin >> n >> k;
    for (int i = 0; i < n; ++ i){
        for (int j = 0, x; j < k; ++ j){
            cin >> x;
            r[j].emplace_back(x, i);
        }
    }

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

    for (int i = 0; i < k; ++ i) sort(r[i].begin(), r[i].end());
    int ans = 0;
    while (ans < n){
        vector <int> pass;
        for (int i = 0; i < k; ++ i){
            while (id[i] < n && p[i] >= r[i][id[i]].fi){
                int t = r[i][id[i]].se;
                can[t] ++; id[i] ++;
                if (can[t] == k) pass.push_back(t);
            }
        }
        if (pass.empty()) break;
        ans += int(pass.size());
        for (int i : pass){
            for (int j = 0; j < k; ++ j) p[j] = min(mod, p[j] + u[i][j]);
        }
    }

    cout << ans;
}

int main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

Main.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
Main.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
Main.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
Main.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
Main.cpp: In function 'int main()':
Main.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 47700 KB Output is correct
2 Correct 9 ms 47700 KB Output is correct
3 Correct 11 ms 48224 KB Output is correct
4 Correct 174 ms 102248 KB Output is correct
5 Correct 181 ms 102192 KB Output is correct
6 Correct 210 ms 102324 KB Output is correct
7 Correct 140 ms 90444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 47700 KB Output is correct
2 Correct 10 ms 47700 KB Output is correct
3 Correct 9 ms 47700 KB Output is correct
4 Correct 10 ms 47700 KB Output is correct
5 Correct 10 ms 47868 KB Output is correct
6 Correct 8 ms 47700 KB Output is correct
7 Correct 14 ms 47956 KB Output is correct
8 Correct 12 ms 48148 KB Output is correct
9 Correct 12 ms 47956 KB Output is correct
10 Correct 11 ms 48084 KB Output is correct
11 Correct 11 ms 47968 KB Output is correct
12 Correct 11 ms 47956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 47700 KB Output is correct
2 Correct 8 ms 47700 KB Output is correct
3 Correct 11 ms 48360 KB Output is correct
4 Correct 35 ms 53656 KB Output is correct
5 Correct 35 ms 53328 KB Output is correct
6 Correct 288 ms 109492 KB Output is correct
7 Correct 465 ms 104508 KB Output is correct
8 Correct 297 ms 109512 KB Output is correct
9 Correct 484 ms 104396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 47700 KB Output is correct
2 Correct 9 ms 47700 KB Output is correct
3 Correct 11 ms 48224 KB Output is correct
4 Correct 174 ms 102248 KB Output is correct
5 Correct 181 ms 102192 KB Output is correct
6 Correct 210 ms 102324 KB Output is correct
7 Correct 140 ms 90444 KB Output is correct
8 Correct 10 ms 47700 KB Output is correct
9 Correct 10 ms 47700 KB Output is correct
10 Correct 9 ms 47700 KB Output is correct
11 Correct 10 ms 47700 KB Output is correct
12 Correct 10 ms 47868 KB Output is correct
13 Correct 8 ms 47700 KB Output is correct
14 Correct 14 ms 47956 KB Output is correct
15 Correct 12 ms 48148 KB Output is correct
16 Correct 12 ms 47956 KB Output is correct
17 Correct 11 ms 48084 KB Output is correct
18 Correct 11 ms 47968 KB Output is correct
19 Correct 11 ms 47956 KB Output is correct
20 Correct 8 ms 47700 KB Output is correct
21 Correct 8 ms 47700 KB Output is correct
22 Correct 11 ms 48360 KB Output is correct
23 Correct 35 ms 53656 KB Output is correct
24 Correct 35 ms 53328 KB Output is correct
25 Correct 288 ms 109492 KB Output is correct
26 Correct 465 ms 104508 KB Output is correct
27 Correct 297 ms 109512 KB Output is correct
28 Correct 484 ms 104396 KB Output is correct
29 Correct 215 ms 80464 KB Output is correct
30 Correct 226 ms 77232 KB Output is correct
31 Correct 245 ms 78960 KB Output is correct
32 Correct 162 ms 71220 KB Output is correct
33 Correct 175 ms 69844 KB Output is correct
34 Correct 204 ms 73292 KB Output is correct
35 Correct 226 ms 75336 KB Output is correct
36 Correct 204 ms 76364 KB Output is correct
37 Correct 214 ms 79112 KB Output is correct
38 Correct 162 ms 67952 KB Output is correct