답안 #828103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828103 2023-08-17T04:44:27 Z 박상훈(#10381) Topical (NOI23_topical) C++17
100 / 100
586 ms 163788 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int n, k;
vector<int> u[1001000], r[1001000];

int pt[1001000], val[1001000], deg[1001000];
vector<pair<int, int>> p[1001000];
vector<int> que;

void push(int j, int x){
	val[j] += x;
	while(pt[j]<n && p[j][pt[j]].first <= val[j]){
		int v = p[j][pt[j]].second;
		deg[v]--;
		if (deg[v]==0) que.push_back(v);

		pt[j]++;
	}
}

int main(){
	scanf("%d %d", &n, &k);
	for (int i=1;i<=n;i++){
		r[i].resize(k+1);
		for (int j=1;j<=k;j++){
			scanf("%d", &r[i][j]);
			p[j].emplace_back(r[i][j], i);
		} 

		deg[i] = k;
	}

	for (int i=1;i<=n;i++){
		u[i].resize(k+1);
		for (int j=1;j<=k;j++){
			scanf("%d", &u[i][j]);
		}
	}

	for (int i=1;i<=k;i++) sort(p[i].begin(), p[i].end());
	for (int i=1;i<=k;i++) push(i, 0);

	int ans = 0;
	while(!que.empty()){
		int cur = que.back(); que.pop_back();
		ans++;
		for (int j=1;j<=k;j++) push(j, u[cur][j]);
	}

	printf("%d\n", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  scanf("%d %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:29:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |    scanf("%d", &r[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |    scanf("%d", &u[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 70860 KB Output is correct
2 Correct 31 ms 70852 KB Output is correct
3 Correct 33 ms 71364 KB Output is correct
4 Correct 245 ms 129420 KB Output is correct
5 Correct 263 ms 129424 KB Output is correct
6 Correct 245 ms 129420 KB Output is correct
7 Correct 233 ms 119712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 70752 KB Output is correct
2 Correct 30 ms 70828 KB Output is correct
3 Correct 31 ms 70824 KB Output is correct
4 Correct 31 ms 70728 KB Output is correct
5 Correct 31 ms 70764 KB Output is correct
6 Correct 31 ms 70752 KB Output is correct
7 Correct 33 ms 71208 KB Output is correct
8 Correct 32 ms 71172 KB Output is correct
9 Correct 32 ms 71060 KB Output is correct
10 Correct 33 ms 71084 KB Output is correct
11 Correct 32 ms 71200 KB Output is correct
12 Correct 33 ms 71212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 70768 KB Output is correct
2 Correct 31 ms 70796 KB Output is correct
3 Correct 34 ms 71692 KB Output is correct
4 Correct 76 ms 79760 KB Output is correct
5 Correct 71 ms 79448 KB Output is correct
6 Correct 548 ms 163732 KB Output is correct
7 Correct 539 ms 158568 KB Output is correct
8 Correct 586 ms 163788 KB Output is correct
9 Correct 555 ms 158648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 70860 KB Output is correct
2 Correct 31 ms 70852 KB Output is correct
3 Correct 33 ms 71364 KB Output is correct
4 Correct 245 ms 129420 KB Output is correct
5 Correct 263 ms 129424 KB Output is correct
6 Correct 245 ms 129420 KB Output is correct
7 Correct 233 ms 119712 KB Output is correct
8 Correct 31 ms 70752 KB Output is correct
9 Correct 30 ms 70828 KB Output is correct
10 Correct 31 ms 70824 KB Output is correct
11 Correct 31 ms 70728 KB Output is correct
12 Correct 31 ms 70764 KB Output is correct
13 Correct 31 ms 70752 KB Output is correct
14 Correct 33 ms 71208 KB Output is correct
15 Correct 32 ms 71172 KB Output is correct
16 Correct 32 ms 71060 KB Output is correct
17 Correct 33 ms 71084 KB Output is correct
18 Correct 32 ms 71200 KB Output is correct
19 Correct 33 ms 71212 KB Output is correct
20 Correct 35 ms 70768 KB Output is correct
21 Correct 31 ms 70796 KB Output is correct
22 Correct 34 ms 71692 KB Output is correct
23 Correct 76 ms 79760 KB Output is correct
24 Correct 71 ms 79448 KB Output is correct
25 Correct 548 ms 163732 KB Output is correct
26 Correct 539 ms 158568 KB Output is correct
27 Correct 586 ms 163788 KB Output is correct
28 Correct 555 ms 158648 KB Output is correct
29 Correct 272 ms 107008 KB Output is correct
30 Correct 259 ms 104004 KB Output is correct
31 Correct 303 ms 106656 KB Output is correct
32 Correct 233 ms 97700 KB Output is correct
33 Correct 236 ms 96780 KB Output is correct
34 Correct 266 ms 99136 KB Output is correct
35 Correct 295 ms 103248 KB Output is correct
36 Correct 250 ms 102240 KB Output is correct
37 Correct 273 ms 105028 KB Output is correct
38 Correct 273 ms 95940 KB Output is correct