# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
510904 |
2022-01-15T03:44:17 Z |
KoD |
Akcija (COCI21_akcija) |
C++17 |
|
23 ms |
29168 KB |
#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
using i64 = std::int64_t;
constexpr i64 inf = std::numeric_limits<i64>::max() / 2;
void setmin(i64& x, const i64 y) {
if (x > y) {
x = y;
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, K;
std::cin >> N >> K;
vector<pair<int, int>> prod(N);
for (auto& [d, w] : prod) {
std::cin >> w >> d;
}
std::sort(prod.begin(), prod.end());
if (K == 1) {
vector dp(N + 1, vector<i64>(N + 1, inf));
setmin(dp[0][0], 0);
for (int i = 0; i < N; ++i) {
const auto& [d, w] = prod[i];
for (int j = 0; j <= N; ++j) {
if (dp[i][j] == inf) continue;
if (d > j) {
setmin(dp[i + 1][j + 1], dp[i][j] + w);
} else {
setmin(dp[i + 1][j], dp[i][j]);
}
}
}
int j = 0;
while (j < N and dp[N][j + 1] != inf) {
j += 1;
}
std::cout << j << ' ' << dp[N][j] << '\n';
} else if (N <= 20) {
vector<pair<int, i64>> cand;
for (int set = 0; set < (1 << N); ++set) {
bool ok = true;
int k = 0;
i64 c = 0;
for (int i = 0; i < N; ++i) {
if (set >> i & 1) {
const auto& [d, w] = prod[i];
}
}
}
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:55:33: warning: unused structured binding declaration [-Wunused-variable]
55 | const auto& [d, w] = prod[i];
| ^~~~~~
Main.cpp:50:18: warning: unused variable 'ok' [-Wunused-variable]
50 | bool ok = true;
| ^~
Main.cpp:51:17: warning: unused variable 'k' [-Wunused-variable]
51 | int k = 0;
| ^
Main.cpp:52:17: warning: unused variable 'c' [-Wunused-variable]
52 | i64 c = 0;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
29168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
29168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
29168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |