제출 #1250776

#제출 시각아이디문제언어결과실행 시간메모리
1250776nasjesTopical (NOI23_topical)C++20
100 / 100
983 ms344852 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; const ll dim = 2*(1e6)+7; //const ll mod = 1e9 + 7; const ll inf = 1e17 + 77; //#define endl "\n" #define fi first #define pb push_back #define se second #define vll vector<ll> ll n, m, k; ll t; vll a[dim]; vll add[dim]; vector<pll> b[dim]; ll dp[dim]; ll pnt[dim]; ll cnt[dim]; int main() { ll u, w,q, v, y; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; map<ll, ll> mp; for(int i=1; i<=k; i++){ b[i].resize(n+5); pnt[i]=1; } for(int i=1; i<=n; i++){ a[i].resize(k+5); for(int j=1; j<=k;j++){ cin>>a[i][j]; b[j][i].fi=a[i][j]; b[j][i].se=i; } } for(int i=1; i<=k; i++){ sort(b[i].begin()+1, b[i].begin()+1+n); cnt[i]=0; } for(int i=1; i<=n; i++){ add[i].resize(k+5); for(int j=1; j<=k;j++){ cin>>add[i][j]; } } ll ans=0; ll fl=1; while(fl) { fl=0; for (int i = 1; i <= k; i++) { ll p1 = pnt[i]; while (b[i][p1].fi <= cnt[i] && p1 <= n) { if(mp[b[i][p1].se]>=k-1){ fl=1; ans++; ll id=b[i][p1].se; for(int j=1; j<=k; j++){ cnt[j]+=add[id][j]; } } mp[b[i][p1].se]++; p1++; } pnt[i] = p1; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...