#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;
cout << (a[0]==vector<ll>(m));
exit(0);
queue<int> q;
vector<int> cnt(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)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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
104 ms |
23940 KB |
Output is correct |
5 |
Correct |
103 ms |
23912 KB |
Output is correct |
6 |
Correct |
102 ms |
23752 KB |
Output is correct |
7 |
Correct |
77 ms |
23752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
424 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
104 ms |
23940 KB |
Output is correct |
5 |
Correct |
103 ms |
23912 KB |
Output is correct |
6 |
Correct |
102 ms |
23752 KB |
Output is correct |
7 |
Correct |
77 ms |
23752 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |