Submission #946869

# Submission time Handle Problem Language Result Execution time Memory
946869 2024-03-15T06:58:46 Z josanneo22 Topical (NOI23_topical) C++17
12 / 100
119 ms 27804 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define L(i, j, k) for (int i = (j); i <= (k); ++i) 
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define rep0(i, n) L(i, 0, n - 1)
#define rep1(i, n) L(i, 1, n)


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

	int n, k; cin >> n >> k;
	vector<vector<int>> r(n, vector<int>(k)), u(n, vector<int>(k));
	rep0(i, n) rep0(j, k) cin >> r[i][j];
	rep0(i, n) rep0(j, k) cin >> u[i][j];

	vector<int> ord(n);
	iota(ord.begin(), ord.end(), 0);
	sort(ord.begin(), ord.end(), [&](int i, int j){
		rep0(p, k) if(r[i][p] != r[j][p]) return r[i][p] < r[j][p];
		return true;
	});

	vector<int> sum(k);
	vector<bool> vis(n);
	int ans = 0;
	rep1(loop, n){
		// cout << "loop " << loop << '\n';
		for (auto & i : ord) {
			if (vis[i]) continue;
			// cout << "try : " << i + 1 << '\n';
			bool ok = true;
			rep0(j, k) if (r[i][j] > sum[j]) ok = false;
			if (ok) {
				// cout << "eat : " << i + 1 << '\n';
				vis[i] = true;
				rep0(j, k) sum[j] += u[i][j];
				// rep0(j, k) cout << sum[j] << " \n"[j == k - 1];
				ans++;
			}
		}
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 116 ms 27660 KB Output is correct
5 Correct 119 ms 27804 KB Output is correct
6 Correct 119 ms 27656 KB Output is correct
7 Correct 88 ms 21784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 2 ms 604 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 4 ms 3028 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 116 ms 27660 KB Output is correct
5 Correct 119 ms 27804 KB Output is correct
6 Correct 119 ms 27656 KB Output is correct
7 Correct 88 ms 21784 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 2 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -