Submission #1125808

#TimeUsernameProblemLanguageResultExecution timeMemory
1125808thunoproTopical (NOI23_topical)C++17
12 / 100
261 ms122072 KiB
#include<bits/stdc++.h> using namespace std; #define maxn 1000009 #define ll long long #define fi first #define se second #define pb push_back #define re exit(0); #define left id<<1 #define right id<<1|1 #define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin() + 1 const int mod = 1e9+7; const int INF = 1e9; typedef vector<int> vi ; typedef pair<int,int> pii ; typedef vector<pii> vii ; void add ( int &a , int b ) { a += b ; if ( a >= mod ) a -= mod ; if ( a < 0 ) a += mod ; } template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; } template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; } void runfile() { freopen ("bai1.inp","r",stdin) ; } int _pow ( int a , int n ) { if ( n == 0 ) return 1 ; int res = _pow (a,n/2) ; if ( n % 2 ) return 1ll*res*res%mod*a%mod ; else return 1ll*res*res%mod ; } int n , k ; vector<int> r [maxn] , u[maxn] ; int p [maxn] ; int cnt [maxn] ; vector<pii> requires [maxn] ; bool cmp ( pii u , pii v ) { return u.fi < v.fi ; } int cur [maxn] ; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); // runfile() ; cin >> n >> k ; for ( int i = 1 ; i <= n ; i ++ ) r [i].resize(k+2) , u [i].resize(k+2) ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= k ; j ++ ) cin >> r [i][j] ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= k ; j ++ ) cin >> u [i][j] ; for ( int i = 1 ; i <= k ; i ++ ) p [i] = 0 ; for ( int j = 1 ; j <= k ; j ++ ) requires[j].resize(n+2) ; for ( int j = 1 ; j <= k ; j ++ ) for ( int i = 1 ; i <= n ; i ++ ) requires [j][i] = {r[i][j],i} ; for ( int j = 1 ; j <= k ; j ++ ) sort (requires[j].begin()+1,requires[j].begin()+n+1,cmp) ; for ( int j = 1 ; j <= k ; j ++ ) cur [j] = 1 ; vector<int> update ; for ( int j = 1 ; j <= k ; j ++ ) update . pb (j) ; int res = 0 ; while ( true ) { if ( update.empty() ) break ; int x = update.back () ; update.pop_back () ; while ( cur [x] <= n && p [x] >= requires[x][cur[x]].fi ) { if ( ++ cnt[requires[x][cur[x]].se] == k ) { for ( int j = 1 ; j <= k ; j ++ ) p [j] += u [requires[x][cur[x]].se][j] , update . pb (j) ; res ++ ; } ++ cur [x] ; } } cout << res ; }

Compilation message (stderr)

Main.cpp: In function 'void runfile()':
Main.cpp:29:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 | void runfile() { freopen ("bai1.inp","r",stdin) ; }
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...