제출 #1287449

#제출 시각아이디문제언어결과실행 시간메모리
1287449bnijaamaaTopical (NOI23_topical)C++20
33 / 100
230 ms32592 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define nn '\n' const int N = 2e5 + 1; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; if (n == 1) { int r[n + 1][k + 1], u[n + 1][k + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> r[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> u[i][j]; } } int cnt = 0; int mus = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { if (mus >= r[i][j]) { mus += u[i][j]; cnt++; } } } if (cnt == k) { cout << 1 << nn; } else { cout << 0 << nn; } } else { vector < int > a(n + 1), b(n + 1); vector < pair < int, int >> p; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { cin >> b[i]; } for (int i = 1; i <= n; i++) { p.pb({ a[i], b[i] }); } int cnt = 0, sum = 0; sort(p.begin(), p.end()); vector<bool> ok(1e6 + 1 , true); for (int i = 0; i < n; i++) { if(!ok[i]) continue; if (sum >= p[i].first) { sum += p[i].second; ok[i] = false; cnt++; } } // for(auto [x , y] : p) cout << x << ' ' << y << nn ; cout << cnt << nn; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...