QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#427999 | #7279. Tricks of the Trade | Crafticat# | 0 | 4ms | 3732kb | C++14 | 1.5kb | 2024-06-01 16:51:02 | 2024-06-01 16:51:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, k; cin >> n >> k;
vector<int> price(n), sell(n);
for (int i = 0; i < n; ++i) {
cin >> price[i];
}
for (int i = 0; i < n; ++i) {
cin >> sell[i];
}
int ans = -1e18;
vector<bool> appeared(n, false);
for (int i = 0; i < n; ++i) {
multiset<pii> elements;
int buyPrice = 0;
for (int j = i; j < n; ++j) {
elements.emplace(-sell[j],j);
buyPrice += price[j];
if (elements.size() >= k) {
int sellPrice = 0;
int comp = 0;
for (auto [p,ind] : elements) {
sellPrice -= p;
if (++comp >= k) break;
}
int profit = sellPrice - buyPrice;
if (profit > ans) {
ans = profit;
appeared.clear();
appeared.resize(n);
}
if (profit == ans) {
comp = 0;
for (auto [p,ind] : elements) {
appeared[ind] = true;
if (++comp >= k) break;
}
}
}
}
}
cout << ans << "\n";
for (auto b : appeared)
cout << (b ? "1" : "0");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3512kb
input:
5 3 3 5 2 3 6 2 1 5 2 3
output:
-1 00111
result:
ok all correct
Test #2:
score: 10
Accepted
time: 4ms
memory: 3732kb
input:
200 40 81 50 87 91 54 1 77 68 19 84 28 81 45 64 4 13 25 89 12808135 86 40 73 47 18 82 79 11 96 16 34 80 36 8 5 60 76 86 84 36 37 96 55 68 12807879 51 89 57 30 100 11 44 19 96 32 9 68 41 12808009 5 58 12807939 92 68 67 78 32 57 49 71 92 64 35 89 76 81 36 6 6 53 31 85 79 5 85 1 91 17 37 25 91 54 29 47...
output:
12807909 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111000000000000000000000000000000000000
result:
ok all correct
Test #3:
score: 0
Wrong Answer
time: 3ms
memory: 3476kb
input:
200 41 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1294967377 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111110000000000000000001111111111111111111000000
result:
wrong answer wrong answer on the first question
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Time Limit Exceeded
Test #30:
score: 10
Accepted
time: 0ms
memory: 3496kb
input:
5 2 1 6 1 5 2 4 1 6 2 4
output:
2 10111
result:
ok all correct
Test #31:
score: 0
Time Limit Exceeded
input:
250000 2 18 35 29 35 18 610084694 18 35 29 35 18 448867144 18 35 29 35 18 971272498 18 35 29 35 18 890430190 18 35 29 35 18 655685684 18 35 29 35 18 234608237 18 35 29 35 18 894586749 18 35 29 35 18 442195168 18 35 29 35 18 341564617 18 35 29 35 18 985069087 18 35 29 35 18 967546483 18 35 29 35 18 5...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%