답안 #873521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873521 2023-11-15T08:53:52 Z dsyz Topical (NOI23_topical) C++17
100 / 100
424 ms 98192 KB
//23 minutes
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,K;
	cin>>N>>K;
	priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > pq[K];
	ll need[N][K];
	for(ll i = 0;i < N;i++){
		for(ll j = 0;j < K;j++){
			cin>>need[i][j];
			pq[j].push({need[i][j],i});
		}
	}
	ll gain[N][K];
	for(ll i = 0;i < N;i++){
		for(ll j = 0;j < K;j++){
			cin>>gain[i][j];
		}
	}
	ll numoftopic[N];
	memset(numoftopic,0,sizeof(numoftopic));
	ll curtopic[K];
	memset(curtopic,0,sizeof(curtopic));
	queue<ll> can;
	ll sum = 0;
	for(ll i = 0;i < N;i++){
		for(ll j = 0;j < K;j++){
			while(!pq[j].empty() && pq[j].top().first <= curtopic[j]){
				numoftopic[pq[j].top().second]++;
				if(numoftopic[pq[j].top().second] >= K){
					can.push(pq[j].top().second);
				}
				pq[j].pop();
			}
		}
		while(!can.empty()){
			sum++;
			ll x = can.front();
			for(ll j = 0;j < K;j++){
				curtopic[j] += gain[x][j];
			}
			can.pop();
		}
	}
	cout<<sum<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1368 KB Output is correct
4 Correct 197 ms 98132 KB Output is correct
5 Correct 199 ms 98192 KB Output is correct
6 Correct 197 ms 98132 KB Output is correct
7 Correct 164 ms 92272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 836 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 1040 KB Output is correct
4 Correct 32 ms 5900 KB Output is correct
5 Correct 24 ms 5588 KB Output is correct
6 Correct 424 ms 57116 KB Output is correct
7 Correct 382 ms 53172 KB Output is correct
8 Correct 406 ms 57780 KB Output is correct
9 Correct 424 ms 53356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1368 KB Output is correct
4 Correct 197 ms 98132 KB Output is correct
5 Correct 199 ms 98192 KB Output is correct
6 Correct 197 ms 98132 KB Output is correct
7 Correct 164 ms 92272 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 3 ms 836 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 3 ms 1040 KB Output is correct
23 Correct 32 ms 5900 KB Output is correct
24 Correct 24 ms 5588 KB Output is correct
25 Correct 424 ms 57116 KB Output is correct
26 Correct 382 ms 53172 KB Output is correct
27 Correct 406 ms 57780 KB Output is correct
28 Correct 424 ms 53356 KB Output is correct
29 Correct 256 ms 54612 KB Output is correct
30 Correct 263 ms 49660 KB Output is correct
31 Correct 311 ms 47956 KB Output is correct
32 Correct 193 ms 45652 KB Output is correct
33 Correct 191 ms 42248 KB Output is correct
34 Correct 235 ms 44628 KB Output is correct
35 Correct 276 ms 44708 KB Output is correct
36 Correct 249 ms 47868 KB Output is correct
37 Correct 282 ms 50772 KB Output is correct
38 Correct 198 ms 36884 KB Output is correct