# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1262096 | namhh | Topical (NOI23_topical) | C++20 | 348 ms | 156988 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e6+5;
int n,k;
vector<int>a[N],b[N];
vector<pii>rem[N];
int cur[N],cnt[N],val[N];
// ga qua phai chef code huhu :<
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n; i++){
a[i].resize(k+2);
b[i].resize(k+2);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++){
cin >> a[i][j];
rem[j].push_back({a[i][j],i});
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++) cin >> b[i][j];
}
for(int i = 1; i <= k; i++) sort(rem[i].begin(),rem[i].end());
int ans = 0;
for(int i = 1; i <= n; i++){
bool emilia = false;
for(int j = 1; j <= k; j++){
while(cur[j] < n){
auto[x,y] = rem[j][cur[j]];
if(x <= val[j]){
cur[j]++;
cnt[y]++;
if(cnt[y] == k){
for(int l = 1; l <= k; l++) val[l] += b[y][l];
emilia = true;
ans++;
}
}
else break;
}
}
if(emilia == false) break;
}
cout << ans;
}
//
// +.::=. .*: -.
// -- :. = -:--
// .= .. .-=++*+++=:. = :
// .= ....:=%@@@@@*: . :.
// .-+=..: :. .+##%##+. .: .+:
// :*@**%* .. :. ::..:.:. --:
// .--. +@@@@@%: .==: .###@*
// :-- -: -:@@@@# - =@@@@#. .= : +
// .: -=--==: == +- :*%*++= .:#
// -. .:. . +. -*. =@@. .-. .=
// +=.. .. -- .* .#. +@# - :==*=
// .=.+=:::: =. =- ##@+ :--+.#@%++%*
// .++@@: = + .%%%%@@@@@@@@@@@@@@%. :-@#-: -@.
// :@@@@= .+ .= *# .#@.=- =@::-:@:
// :-@@%. -- -- :@*. .%# +. - ** :=%. .*@#
// :-. .-*-. -: +. %-=::@# .* : - :%- +%.+@+@@
// .- :. **: +: = # : =* =@# -= # #@@@:-@ :*@@. %@
// -=: :: .* .= + # =..@ .*. +. *. *#=.+%@*-%* %@
// :=. :.. .: +. -= .+ # -- #. =- .+ +: =@+ .+-++ @%
// ++-=. * -- := # :- +- :* =:+: -@# :@#*%@@@%@+
// *. -- -- := # .= #@#=. +- :=+: :%@-#@@@#@+:@@#
// + +. -- := # .= := .+. +*. *@@+=@-=@*-.#@.
// = + := .+ # = .= .#.-@. -+ .%# -@@= @#
// .= .= .+ + *. = .+.. :*@ == =@. -#@#: @%
// .= .= * + =: .=.**: =--: # * *- %* =*=@+#@:
// .= := # =. .+ . .= --.#@@@@@#@@@: * -= #..@= **:@@@:
// + .= +: -- + # := +@%:@#: -:%= === #..* .#@@%@+.@@+
// * .= .* .= -:-= :- #= ++ =- =@. *: .* -*: : . .@@%
// * + * +. :- # -- # *: .@@ %- + =- +-.- :. .@@@.
// -: =: := .* +.-- =:-- .*.:.: # .= + *+ - :@%@=
// + * *:+. == .+ +. +.# .=-:=- -- -- =+: = -@#%*
// + -= *== *. -=-- :+-= ::: =: + %:. = %@+##
// .= +: +*- + +:+. +:*. .+ +: #.:. - .+ -@@=#%
// -. =. :=#- := =:* .-==#+- +: =- +:-..- :%* =@@:*%
// .- +. --+= .**%+-:. -* +-:*:.:. =@@* :-@@ *%
// -. += -+== -*#- =- .. .%@#@=.--@* *%
// =. .+: :+-*-=+: +%+*@@%%@-= +@- *#
// -::= :**=: :@@@@@@%@@- #@ #*
// -: +: - .@@#%@@%@@: :@# .#+
// :- :#= -- :@@@#@-=@#. =@- .%=
// =:.@@%= =# .+.=. +@@@@* -*: #% :@:
// .+ *@@@@@@@@* :@@*@@@* .@+ -@.
// .+=%@*%@@@@@#: =@@@%:.: +@: +%
// .=%@%#@@@@##@*: =%@@@#: @# ##
// :#@%@@@@#@@@@+ :*. @: =@- .@+
// .+@%#%@@:=-.. .=: %*==+. @% -@-
// =. =: :-:.:: .-- .= -: =@- -
// .- :-. :: .- =-:
// .=+-.=-.*- = -..+*: .-:.- = .+*# ....
// =. -= -: .. -. +. -. +. -+ -*=: +.
// .- +- * -.* #+ .+ =. :=
// :- --=*: -+ *= -# - -##+-.. .:+#: +.
// :- = --=:==+*. =: .: .= =**= = .+
// .= + =-- :- .=. -- .- =
// = .- --: .-+*@%*# +. + :-
// + +- -:- :*@@@@@@*@#*@@%*=: =: - -.
// .* - ::+ =@@@@#-.-@@%%@@+=%@@@%= -:: = :-
// .+ :. +-. #@@@= +@@@-#@@%. +@@@+ .:= .- +:
// .--. -. :=- :@@+ :@@@@# =@@@# -%@# -= :: :-+-
// * - + --. +@@#=%@@@@@. :@@@@% :%@ := =. -=+
// .-**- -. -- .%@@@@+%@+ @@+%@@*-+@@@. :=. - :+*-
// :===-==. .-= *@% *@= +%%##=. :=: :. .::-==-.
// .::-=+=+=-:. #%: -#: .-*#+===-:.
// ..::---====---::.
# | 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... |