Submission #933168

#TimeUsernameProblemLanguageResultExecution timeMemory
933168zhaohaikunTopical (NOI23_topical)C++17
100 / 100
416 ms163288 KiB
// 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? */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...