Submission #1102744

# Submission time Handle Problem Language Result Execution time Memory
1102744 2024-10-18T18:47:40 Z ttamx Topical (NOI23_topical) C++17
21 / 100
533 ms 140516 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<ll>> a(n,vector<ll>(m)),b(n,vector<ll>(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<bool> vis(n);
    vector<ll> val(n);
    vector<priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>> pq(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]>0){
                pq[j].emplace(a[i][j],i);
            }else{
                cnt[i]++;
            }
        }
        if(cnt[i]==m){
            vis[i]=true;
            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){
                    assert(!vis[v]);
                    vis[v]=true;
                    q.emplace(v);
                }
            }
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 592 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 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 0 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 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 5 ms 1872 KB Output is correct
4 Correct 36 ms 15684 KB Output is correct
5 Correct 36 ms 15812 KB Output is correct
6 Correct 533 ms 140516 KB Output is correct
7 Correct 474 ms 140356 KB Output is correct
8 Correct 474 ms 140448 KB Output is correct
9 Correct 488 ms 140324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 592 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -