이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool cmp(pair<int,int> a, pair<int,int> b){
return a.second < b.second;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k; cin>>n>>k;
vector<vector<int>> r(n,vector<int>(k,0)); auto u = r;
for(auto& x : r){
for(auto& i : x) cin>>i;
}
for(auto& x : u){
for(auto& i : x) cin>>i;
}
vector<vector<tuple<int,int,int>>> idx(k);
vector<int> pt(k);
for(int i = 0; i<k; i++){
for(int j = 0; j<n; j++){
idx[i].push_back({r[j][i], -u[j][i],j});
}
sort(idx[i].begin(), idx[i].end());
// can go from i to i+1 if and only if in this topic if r[i][j] + u[i][j] >= r[z][j]
}
// for all i, just see until where can i get
vector<vector<int>> used(n, vector<int>(k,0));
for(int i = 0; i<k; i++){
int act = 0;
for(auto x : idx[i]){
int rt,ut,id;
tie(rt,ut,id) = x;
if(rt <= act){
act+= ut; used[id][i] = 1;
}
}
}
int ans = 0;
for(auto i : used){
int s = 0;
for(int j : i) s+=j;
if(s == k) ans++;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |