QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#875479 | #9684. 倾诉 | testngifaicnslvthis# | 0 | 8ms | 3584kb | C++14 | 2.0kb | 2025-01-29 20:41:26 | 2025-01-29 20:41:26 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
bool check(int n, int k, vector<int> a, int target_max_worry) {
vector<int> current_worries = a;
for (int op = 0; op < k; ++op) {
int max_worry = *max_element(current_worries.begin(), current_worries.end());
if (max_worry <= target_max_worry) {
return true;
}
int best_confider = -1;
int min_next_max_worry = max_worry + 1;
for (int p = 0; p < n - 1; ++p) {
vector<int> next_worries = current_worries;
next_worries[p + 1] += next_worries[p] / 2;
next_worries[p] /= 2;
int next_max_worry = *max_element(next_worries.begin(), next_worries.end());
if (next_max_worry < min_next_max_worry) {
min_next_max_worry = next_max_worry;
best_confider = p;
}
}
if (best_confider == -1) {
break;
}
current_worries[best_confider + 1] += current_worries[best_confider] / 2;
current_worries[best_confider] /= 2;
}
return *max_element(current_worries.begin(), current_worries.end()) <= target_max_worry;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int low = 0, high = *max_element(a.begin(), a.end());
int min_max_worry = high;
while (low <= high) {
int mid = low + (high - low) / 2;
if (check(n, k, a, mid)) {
min_max_worry = mid;
high = mid - 1;
} else {
low = mid + 1;
}
}
i64 s = (i64)min_max_worry;
for (int i = 0; i < k; ++i) {
s *= 2;
}
if (s == 0) {
cout << 0 << '\n';
} else {
string binary_s = "";
while (s > 0) {
binary_s = (s % 2 == 0 ? "0" : "1") + binary_s;
s /= 2;
}
cout << binary_s << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
5 6 1 11764 28428 28179 18698 6443 20288 6 3 29 17548 61962 31242 8172 4107 6 15 7 2 239427 137145 171239 3 6 4 294 211 407 190 2 2 6 5 197190 265870 12121 144584 21313 14169
output:
1101111000011000 1111001000001010000 111010011101000011000000000000000 1001001100000 10100001001100011000000
result:
wrong answer 1st lines differ - expected: '110111100001100000000', found: '1101111000011000'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Wrong Answer
Test #60:
score: 0
Wrong Answer
time: 8ms
memory: 3584kb
input:
1666 6 1 282 719 29 355 388 275 6 1 348 766 91 299 474 96 6 23 5 2 8554 8554 8554 2 6 1 84 195 23 37 120 117 6 3 8 3 51 62 28 5 6 3 3 64 64 4 4 2 6 9 5 552 552 552 552 5 6 3 3611 1144 417 3461 459 755 6 3 777 315 1007 5 2 1061 6 6 1300 2101 4 1877 360 2434 6 1 384 713 168 25 524 390 6 3 203 18 305 1...
output:
1100001000 1110110100 1000010110101000000000000000000000000 11110000 110011000 1000000000 1000101000000000000 100010001101000 10000100101000 100110000010000000 10000011000 10011001000 11100101101000000 1100000110100000 1001101111100 101010111100000 10001110000 100101000000 101110101100000 100000000 ...
result:
wrong answer 1st lines differ - expected: '110000100100000', found: '1100001000'
Subtask #6:
score: 0
Time Limit Exceeded
Test #80:
score: 0
Time Limit Exceeded
input:
3333 6 1000000000 131727 7 4 170194 6 59263 6 1000000000 417714 286613 7 310122 6 4 6 1000000000 63764 2430 2696 6699 8478 22261 6 1000000000 217 131 6 1487 2927 2 6 1000000000 26225 27991 3842 72525 4521 5231 6 1000000000 34409 26001 23563 19345 30764 24919 6 1000000000 97981 138532 59280 82393 128...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #4:
0%