답안 #914257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914257 2024-01-21T13:02:53 Z esomer Topical (NOI23_topical) C++17
100 / 100
483 ms 152000 KB
#include<bits/stdc++.h>
 
using namespace std;

void solve(){
    int n, k; cin >> n >> k;
    vector<vector<int>> r(n, vector<int>(k));
    vector<vector<int>> u(n, vector<int>(k));
    for(vector<int>&v : r){
        for(int& x : v) cin >> x;
    }
    for(vector<int>&v : u){
        for(int& x : v) cin >> x;
    }
    r.push_back(vector<int>(k, 0));
    u.push_back(vector<int>(k, 0));
    vector<vector<pair<int, int>>> topics(k);
    for(int j = 0; j < k; j++){
        for(int i = 0; i < n; i++){
            topics[j].push_back({r[i][j], i});
        }
        sort(topics[j].begin(), topics[j].end());
    }
    vector<int> lst(k, -1), cnt(n, 0);
    queue<int> q; q.push(n);
    vector<int> curr(k, 0);
    int ans = 0;
    // cerr << "here" << endl;
    while(!q.empty()){
        int x = q.front(); q.pop();
        ans++;
        for(int i = 0; i < k; i++){
            curr[i] += u[x][i];
            int nw = lst[i]+1;
            while(nw < n && topics[i][nw].first <= curr[i]){
                lst[i]=nw;
                cnt[topics[i][nw].second]++;
                if(cnt[topics[i][nw].second] == k) q.push(topics[i][nw].second);
                nw++;
            }
        }
    }
    cout << ans - 1 << "\n";
}

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

    // int tt; cin >> tt;
    int tt = 1;
    while(tt--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1372 KB Output is correct
4 Correct 210 ms 90176 KB Output is correct
5 Correct 204 ms 90128 KB Output is correct
6 Correct 195 ms 90248 KB Output is correct
7 Correct 161 ms 84360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 1920 KB Output is correct
4 Correct 38 ms 17716 KB Output is correct
5 Correct 45 ms 15568 KB Output is correct
6 Correct 483 ms 152000 KB Output is correct
7 Correct 452 ms 148160 KB Output is correct
8 Correct 461 ms 150464 KB Output is correct
9 Correct 451 ms 149172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1372 KB Output is correct
4 Correct 210 ms 90176 KB Output is correct
5 Correct 204 ms 90128 KB Output is correct
6 Correct 195 ms 90248 KB Output is correct
7 Correct 161 ms 84360 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 4 ms 1920 KB Output is correct
23 Correct 38 ms 17716 KB Output is correct
24 Correct 45 ms 15568 KB Output is correct
25 Correct 483 ms 152000 KB Output is correct
26 Correct 452 ms 148160 KB Output is correct
27 Correct 461 ms 150464 KB Output is correct
28 Correct 451 ms 149172 KB Output is correct
29 Correct 221 ms 36320 KB Output is correct
30 Correct 209 ms 33268 KB Output is correct
31 Correct 287 ms 40792 KB Output is correct
32 Correct 173 ms 27472 KB Output is correct
33 Correct 172 ms 26336 KB Output is correct
34 Correct 206 ms 27252 KB Output is correct
35 Correct 246 ms 37124 KB Output is correct
36 Correct 202 ms 30328 KB Output is correct
37 Correct 236 ms 32940 KB Output is correct
38 Correct 178 ms 29692 KB Output is correct