답안 #882173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882173 2023-12-02T18:14:58 Z tsumondai Topical (NOI23_topical) C++14
12 / 100
181 ms 101972 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() + 1, 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 6 ms 31064 KB Output is correct
2 Correct 8 ms 35164 KB Output is correct
3 Correct 8 ms 35572 KB Output is correct
4 Correct 181 ms 101972 KB Output is correct
5 Correct 177 ms 101712 KB Output is correct
6 Correct 174 ms 101712 KB Output is correct
7 Correct 136 ms 81748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 33116 KB Output is correct
2 Incorrect 6 ms 33116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31068 KB Output is correct
2 Incorrect 6 ms 31068 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31064 KB Output is correct
2 Correct 8 ms 35164 KB Output is correct
3 Correct 8 ms 35572 KB Output is correct
4 Correct 181 ms 101972 KB Output is correct
5 Correct 177 ms 101712 KB Output is correct
6 Correct 174 ms 101712 KB Output is correct
7 Correct 136 ms 81748 KB Output is correct
8 Correct 7 ms 33116 KB Output is correct
9 Incorrect 6 ms 33116 KB Output isn't correct
10 Halted 0 ms 0 KB -