Submission #1102748

# Submission time Handle Problem Language Result Execution time Memory
1102748 2024-10-18T18:50:27 Z ttamx Topical (NOI23_topical) C++17
100 / 100
533 ms 124340 KB
#include<bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(n,vector<int>(m)),b(n,vector<int>(m));
    for(auto &v:a)for(auto &x:v)cin >> x;
    for(auto &v:b)for(auto &x:v)cin >> x;
    queue<int> q;
    vector<int> cnt(n);
    vector<ll> val(m);
    vector<priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>> pq(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j])pq[j].emplace(a[i][j],i);
            else cnt[i]++;
        }
        if(cnt[i]==m)q.emplace(i);
    }
    int ans=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        ans++;
        for(int i=0;i<m;i++){
            val[i]+=b[u][i];
            while(!pq[i].empty()&&pq[i].top().first<=val[i]){
                int v=pq[i].top().second;
                pq[i].pop();
                cnt[v]++;
                if(cnt[v]==m)q.emplace(v);
            }
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 114 ms 51104 KB Output is correct
5 Correct 113 ms 51200 KB Output is correct
6 Correct 119 ms 51200 KB Output is correct
7 Correct 137 ms 78604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 4 ms 1564 KB Output is correct
4 Correct 46 ms 12824 KB Output is correct
5 Correct 32 ms 12736 KB Output is correct
6 Correct 496 ms 124340 KB Output is correct
7 Correct 525 ms 124288 KB Output is correct
8 Correct 533 ms 124340 KB Output is correct
9 Correct 469 ms 124340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 114 ms 51104 KB Output is correct
5 Correct 113 ms 51200 KB Output is correct
6 Correct 119 ms 51200 KB Output is correct
7 Correct 137 ms 78604 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 592 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 3 ms 592 KB Output is correct
18 Correct 2 ms 592 KB Output is correct
19 Correct 3 ms 592 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 4 ms 1564 KB Output is correct
23 Correct 46 ms 12824 KB Output is correct
24 Correct 32 ms 12736 KB Output is correct
25 Correct 496 ms 124340 KB Output is correct
26 Correct 525 ms 124288 KB Output is correct
27 Correct 533 ms 124340 KB Output is correct
28 Correct 469 ms 124340 KB Output is correct
29 Correct 195 ms 18820 KB Output is correct
30 Correct 191 ms 16296 KB Output is correct
31 Correct 291 ms 23196 KB Output is correct
32 Correct 136 ms 17224 KB Output is correct
33 Correct 152 ms 16712 KB Output is correct
34 Correct 210 ms 19784 KB Output is correct
35 Correct 277 ms 23204 KB Output is correct
36 Correct 218 ms 19808 KB Output is correct
37 Correct 259 ms 19812 KB Output is correct
38 Correct 125 ms 18856 KB Output is correct