# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
969106 | 2024-04-24T13:52:24 Z | TrendBattles | Gym Badges (NOI22_gymbadges) | C++14 | 106 ms | 4348 KB |
//https://oj.uz/problem/view/NOI22_gymbadges #include <bits/stdc++.h> using namespace std; using lli = int64_t; #define INFILE "NOI22_gymbadges.inp" #define OUTFILE "NOI22_gymbadges.ans" int main() { ios::sync_with_stdio(0); cin.tie(0); if (fopen(INFILE, "r")) { freopen(INFILE, "r", stdin); freopen(OUTFILE, "w", stdout); } int N; cin >> N; vector <int> X(N), L(N); for (int& v : X) cin >> v; for (int& v : L) cin >> v; if (*max_element(L.begin(), L.end()) == *min_element(L.begin(), L.end())) { sort(X.begin(), X.end()); int ans = N; lli sum = 0; for (int i = 0; i < N; ++i) { sum += X[i]; if (sum > L[0]) { ans = i; break; } } cout << ans; return 0; } vector <int> order(N); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&] (int u, int v) { return L[u] < L[v]; }); const lli inf = 0x3f3f3f3f3f3f3f3f; vector <lli> dp(N + 1, inf); dp[0] = 0; for (int i = 0; i < N; ++i) { for (int j = N; j; --j) { if (dp[j - 1] <= L[order[i]]) { dp[j] = min(dp[j], dp[j - 1] + X[order[i]]); } } } for (int i = N; i >= 0; --i) { if (dp[i] < inf) { cout << i; return 0; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 106 ms | 4348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |