답안 #894626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894626 2023-12-28T14:34:56 Z fanwen Topical (NOI23_topical) C++17
100 / 100
405 ms 138156 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define ll long long
#define file(name)                  \
    if(fopen(name".inp", "r"))      \
        freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout); 

void you_make_it(void) {
	int n, m; cin >> n >> m;
	vector <vector <int>> a(n, vector <int> (m));
	vector <vector <int>> s(n, vector <int> (m));
	vector <int> cnt(n);
	vector <vector <pair <int, int>>> val(m);
	vector <long long> p(m);
	queue <int> q;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
			if(a[i][j] == 0) cnt[i]++;
			val[j].emplace_back(a[i][j], i);
		}
		if(cnt[i] == m) q.push(i);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> s[i][j];
		}
	}

	for (int i = 0; i < m; ++i) {
		sort(val[i].begin(), val[i].end(), greater <pair <int,int>> ());
	}

	int ans = 0;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		ans++;

		for (int i = 0; i < m; ++i) {
			p[i] += s[u][i];
			while(!val[i].empty() && val[i].back().fi <= p[i]) {
				if(++cnt[val[i].back().se] == m) {
					q.push(val[i].back().se);
				}
				val[i].pop_back();
			}
		}
	}

	cout << ans;
}

signed main() {

#ifdef LOCAL
    freopen("TASK.inp", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    file("topical");
    auto start_time = chrono::steady_clock::now();

    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);

    you_make_it();

    auto end_time = chrono::steady_clock::now();

    cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;

    return (0 ^ 0);
}

// Dream it. Wish it. Do it.

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:63:5: note: in expansion of macro 'file'
   63 |     file("topical");
      |     ^~~~
Main.cpp:10:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:63:5: note: in expansion of macro 'file'
   63 |     file("topical");
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 1176 KB Output is correct
4 Correct 177 ms 82516 KB Output is correct
5 Correct 185 ms 82444 KB Output is correct
6 Correct 175 ms 82336 KB Output is correct
7 Correct 147 ms 76552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
12 Correct 3 ms 920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 4 ms 1884 KB Output is correct
4 Correct 35 ms 14020 KB Output is correct
5 Correct 30 ms 13776 KB Output is correct
6 Correct 382 ms 138052 KB Output is correct
7 Correct 360 ms 135152 KB Output is correct
8 Correct 405 ms 138156 KB Output is correct
9 Correct 367 ms 135140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 1176 KB Output is correct
4 Correct 177 ms 82516 KB Output is correct
5 Correct 185 ms 82444 KB Output is correct
6 Correct 175 ms 82336 KB Output is correct
7 Correct 147 ms 76552 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 452 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 2 ms 856 KB Output is correct
19 Correct 3 ms 920 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 4 ms 1884 KB Output is correct
23 Correct 35 ms 14020 KB Output is correct
24 Correct 30 ms 13776 KB Output is correct
25 Correct 382 ms 138052 KB Output is correct
26 Correct 360 ms 135152 KB Output is correct
27 Correct 405 ms 138156 KB Output is correct
28 Correct 367 ms 135140 KB Output is correct
29 Correct 205 ms 36688 KB Output is correct
30 Correct 201 ms 33552 KB Output is correct
31 Correct 247 ms 38244 KB Output is correct
32 Correct 173 ms 27800 KB Output is correct
33 Correct 212 ms 26484 KB Output is correct
34 Correct 246 ms 29708 KB Output is correct
35 Correct 227 ms 34552 KB Output is correct
36 Correct 198 ms 32752 KB Output is correct
37 Correct 229 ms 35552 KB Output is correct
38 Correct 149 ms 27104 KB Output is correct