답안 #933168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933168 2024-02-25T07:44:30 Z zhaohaikun Topical (NOI23_topical) C++17
100 / 100
416 ms 163288 KB
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T& x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 1e6 + 10;
vector <int> a[N], b[N];
vector <pair <int, int>> c[N];
int n, k, ans, s[N], t[N], rk[N];//, tim[N], id[N];
// mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
// inline int rnd(int l, int r) {return mrand() % (r - l + 1) + l;}
queue <int> q;
void update(int x) {
	while (rk[x] < n && s[x] >= c[x][rk[x]].first) {
		if (++t[c[x][rk[x]].second] == k) {
			q.push(c[x][rk[x]].second);
		}
		rk[x]++;
	}
}
signed main() {
	read(n), read(k);
	F(i, 1, n) {
		// id[i] = i;
		a[i].resize(k);
		F(j, 0, k - 1) {
			read(a[i][j]);
			c[j].emplace_back(a[i][j], i);
		}
	}
	F(i, 0, k - 1) {
		sort(all(c[i]));
		update(i);
	}
	// shuffle(id + 1, id + n + 1, mrand);
	F(i, 1, n) {
		b[i].resize(k);
		for (int &j: b[i]) read(j);
	}
	while (q.size()) {
		ans++;
		int x = q.front(); q.pop();
		F(i, 0, k - 1) s[i] += b[x][i], update(i);
	}
	cout << ans;
	// F(i, 1, n) {
	// 	F(t, 1, n) {
	// 		F(j, 0, k - 1) {
	// 			if (s[j] >= a[rk[]])
	// 		}
	// 	}
	// }
	return 0;
}
/* why?
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 72028 KB Output is correct
2 Correct 18 ms 72536 KB Output is correct
3 Correct 17 ms 72540 KB Output is correct
4 Correct 116 ms 129312 KB Output is correct
5 Correct 117 ms 129564 KB Output is correct
6 Correct 133 ms 129304 KB Output is correct
7 Correct 87 ms 117004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 72024 KB Output is correct
2 Correct 19 ms 72300 KB Output is correct
3 Correct 16 ms 72028 KB Output is correct
4 Correct 19 ms 72424 KB Output is correct
5 Correct 17 ms 72028 KB Output is correct
6 Correct 18 ms 72280 KB Output is correct
7 Correct 19 ms 72460 KB Output is correct
8 Correct 18 ms 72540 KB Output is correct
9 Correct 18 ms 72540 KB Output is correct
10 Correct 19 ms 72540 KB Output is correct
11 Correct 20 ms 72540 KB Output is correct
12 Correct 18 ms 72540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 72536 KB Output is correct
2 Correct 18 ms 72296 KB Output is correct
3 Correct 23 ms 73044 KB Output is correct
4 Correct 41 ms 81092 KB Output is correct
5 Correct 45 ms 80836 KB Output is correct
6 Correct 392 ms 162848 KB Output is correct
7 Correct 373 ms 159884 KB Output is correct
8 Correct 416 ms 163288 KB Output is correct
9 Correct 361 ms 159900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 72028 KB Output is correct
2 Correct 18 ms 72536 KB Output is correct
3 Correct 17 ms 72540 KB Output is correct
4 Correct 116 ms 129312 KB Output is correct
5 Correct 117 ms 129564 KB Output is correct
6 Correct 133 ms 129304 KB Output is correct
7 Correct 87 ms 117004 KB Output is correct
8 Correct 18 ms 72024 KB Output is correct
9 Correct 19 ms 72300 KB Output is correct
10 Correct 16 ms 72028 KB Output is correct
11 Correct 19 ms 72424 KB Output is correct
12 Correct 17 ms 72028 KB Output is correct
13 Correct 18 ms 72280 KB Output is correct
14 Correct 19 ms 72460 KB Output is correct
15 Correct 18 ms 72540 KB Output is correct
16 Correct 18 ms 72540 KB Output is correct
17 Correct 19 ms 72540 KB Output is correct
18 Correct 20 ms 72540 KB Output is correct
19 Correct 18 ms 72540 KB Output is correct
20 Correct 19 ms 72536 KB Output is correct
21 Correct 18 ms 72296 KB Output is correct
22 Correct 23 ms 73044 KB Output is correct
23 Correct 41 ms 81092 KB Output is correct
24 Correct 45 ms 80836 KB Output is correct
25 Correct 392 ms 162848 KB Output is correct
26 Correct 373 ms 159884 KB Output is correct
27 Correct 416 ms 163288 KB Output is correct
28 Correct 361 ms 159900 KB Output is correct
29 Correct 152 ms 108184 KB Output is correct
30 Correct 146 ms 105300 KB Output is correct
31 Correct 204 ms 105148 KB Output is correct
32 Correct 111 ms 99076 KB Output is correct
33 Correct 122 ms 98012 KB Output is correct
34 Correct 152 ms 100372 KB Output is correct
35 Correct 175 ms 101436 KB Output is correct
36 Correct 163 ms 104116 KB Output is correct
37 Correct 173 ms 106324 KB Output is correct
38 Correct 115 ms 93648 KB Output is correct