제출 #1125806

#제출 시각아이디문제언어결과실행 시간메모리
1125806thunoproTopical (NOI23_topical)C++17
12 / 100
183 ms78664 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+1) , u [i].resize(k+1) ; 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] ; if ( n == 1 ) { for ( int i = 1 ; i <= k ; i ++ ) { if ( r [1][i] ) { cout << 0 ; re } } cout << 1 ; re } for ( int i = 1 ; i <= k ; i ++ ) p [i] = 0 ; for ( int j = 1 ; j <= k ; j ++ ) requires[j].resize(n+1) ; 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 ; int res = 0 ; while ( true ) { bool changed = false ; for ( int j = 1 ; j <= k ; j ++ ) { while ( p [j] >= requires[j][cur[j]].fi ) { if ( ++ cnt [requires[j][cur[j]].se] == k ) { for ( int run = 1 ; run <= k ; run ++ ) { p [run] += u [requires[j][cur[j]].se][run] ; } res ++ ; } cur [j] ++ ; changed = true ; } } if ( changed == false ) break ; } cout << res ; }

컴파일 시 표준 에러 (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...