답안 #882176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882176 2023-12-02T18:17:27 Z tsumondai Topical (NOI23_topical) C++14
100 / 100
247 ms 90192 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define hashR(i,j) r[i*k+j]
#define hashU(i,j) u[i*k+j]

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 1e6 + 5;

const int oo = 1e9, mod = 1e9 + 7;

int r[N], u[N], filled[N], cur[N];

int n, m, k;

vector<ii> reqs[N];
int ind[N];

void process() {
	cin >> n >> k;
	foru(i, 0, n-1) {
		foru(j, 0, k-1) {
			cin >> hashR(i, j);
			reqs[j].pb({hashR(i, j), i});
		}
	}
	foru(i, 0, k-1) sort(reqs[i].begin(), reqs[i].end());
	foru(i, 0, n-1) {
		foru(j, 0, k-1) {
			cin >> hashU(i, j);
		}
	}

	int ans = 0;
	vector<int> nex;
	bool can = 1;
	while (can) {
		can = 0;
		foru(j, 0, k-1) {
			while (ind[j] <= n && reqs[j][ind[j]].fi <= cur[j]) {
				filled[reqs[j][ind[j]].se]++;
				if (filled[reqs[j][ind[j]].se] == k) {
					foru(jj, 0, k-1) {
						cur[jj] += hashU(reqs[j][ind[j]].se, jj);
					}
					ans++;
					can = 1;
				}
				ind[j]++;
			}
		}
	}

	cout << ans;

	return;
}

signed main() {
	cin.tie(0)->sync_with_stdio(false);
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);
	process();
	cerr << "Time elapsed: " << __TIME << " s.\n";
	return 0;
}

/*
Xét các trường hợp đặc biệt
Kiểm tra lại input/output
Cố gắng trâu
Lật ngược bài toán
Keep calm and get VOI
Flow:

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 31068 KB Output is correct
2 Correct 6 ms 35296 KB Output is correct
3 Correct 8 ms 35672 KB Output is correct
4 Correct 175 ms 90048 KB Output is correct
5 Correct 178 ms 90192 KB Output is correct
6 Correct 174 ms 90056 KB Output is correct
7 Correct 131 ms 75720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 33116 KB Output is correct
2 Correct 7 ms 35164 KB Output is correct
3 Correct 6 ms 33112 KB Output is correct
4 Correct 6 ms 31068 KB Output is correct
5 Correct 7 ms 35164 KB Output is correct
6 Correct 7 ms 33244 KB Output is correct
7 Correct 9 ms 33628 KB Output is correct
8 Correct 9 ms 33472 KB Output is correct
9 Correct 8 ms 33884 KB Output is correct
10 Correct 10 ms 33624 KB Output is correct
11 Correct 9 ms 33628 KB Output is correct
12 Correct 9 ms 33624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31068 KB Output is correct
2 Correct 7 ms 33116 KB Output is correct
3 Correct 9 ms 35804 KB Output is correct
4 Correct 30 ms 40488 KB Output is correct
5 Correct 28 ms 40236 KB Output is correct
6 Correct 247 ms 83600 KB Output is correct
7 Correct 241 ms 81840 KB Output is correct
8 Correct 246 ms 83156 KB Output is correct
9 Correct 235 ms 81712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 31068 KB Output is correct
2 Correct 6 ms 35296 KB Output is correct
3 Correct 8 ms 35672 KB Output is correct
4 Correct 175 ms 90048 KB Output is correct
5 Correct 178 ms 90192 KB Output is correct
6 Correct 174 ms 90056 KB Output is correct
7 Correct 131 ms 75720 KB Output is correct
8 Correct 6 ms 33116 KB Output is correct
9 Correct 7 ms 35164 KB Output is correct
10 Correct 6 ms 33112 KB Output is correct
11 Correct 6 ms 31068 KB Output is correct
12 Correct 7 ms 35164 KB Output is correct
13 Correct 7 ms 33244 KB Output is correct
14 Correct 9 ms 33628 KB Output is correct
15 Correct 9 ms 33472 KB Output is correct
16 Correct 8 ms 33884 KB Output is correct
17 Correct 10 ms 33624 KB Output is correct
18 Correct 9 ms 33628 KB Output is correct
19 Correct 9 ms 33624 KB Output is correct
20 Correct 6 ms 31068 KB Output is correct
21 Correct 7 ms 33116 KB Output is correct
22 Correct 9 ms 35804 KB Output is correct
23 Correct 30 ms 40488 KB Output is correct
24 Correct 28 ms 40236 KB Output is correct
25 Correct 247 ms 83600 KB Output is correct
26 Correct 241 ms 81840 KB Output is correct
27 Correct 246 ms 83156 KB Output is correct
28 Correct 235 ms 81712 KB Output is correct
29 Correct 227 ms 84712 KB Output is correct
30 Correct 211 ms 79912 KB Output is correct
31 Correct 245 ms 79528 KB Output is correct
32 Correct 171 ms 75444 KB Output is correct
33 Correct 174 ms 72584 KB Output is correct
34 Correct 206 ms 77144 KB Output is correct
35 Correct 236 ms 76132 KB Output is correct
36 Correct 200 ms 80212 KB Output is correct
37 Correct 225 ms 83044 KB Output is correct
38 Correct 149 ms 69352 KB Output is correct