QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#264913 | #7744. Elevator | ucup-team1264# | RE | 0ms | 3568kb | C++20 | 2.1kb | 2023-11-25 15:59:17 | 2023-11-25 15:59:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define int i64
void solve() {
int n, k;
cin >> n >> k;
multiset<tuple<int, int, int>> st;
multiset<pair<int, int>> stw[3];
int ans = 0;
for (int i = 0; i < n; i++) {
int c, w, f;
cin >> c >> w >> f;
st.insert({f, w, c});
stw[w].insert({f, c});
}
int rem_size = 0;
while (st.size()) {
if (rem_size) {
if (rem_size > 1) {
auto it = --st.end();
auto [f, w, c] = *it;
st.erase(it);
stw[w].extract({f, c});
int use_count = min(rem_size / w, c);
c -= use_count;
rem_size -= use_count * w;
if (c) {
st.insert({f, w, c});
stw[w].insert({f, c});
}
} else {
int w = 1;
auto it = --stw[w].end();
auto [f, c] = *it;
st.extract({f, w, c});
stw[w].erase(it);
int use_count = 1;
c -= use_count;
rem_size -= use_count;
assert(rem_size == 0);
if (c) {
st.insert({f, w, c});
stw[w].insert({f, c});
}
}
} else {
auto it = --st.end();
auto [f, w, c] = *it;
st.erase(it);
stw[w].extract({f, c});
{
int divide = (c * w) / k;
if (divide) {
c -= (divide * k) / w;
ans += divide * f;
}
}
if (c) {
rem_size += k;
ans += f;
st.insert({f, w, c});
stw[w].insert({f, c});
}
}
}
cout << ans << "\n";
}
#undef int
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
2 4 6 1 1 8 7 2 5 1 1 7 3 2 6 8 1200000 100000 1 100000 100000 1 12345 100000 2 100000 100000 2 12345 100000 1 100000 100000 1 12345 100000 2 100000 100000 2 12345
output:
24 100000
result:
ok 2 lines
Test #2:
score: -100
Runtime Error
input:
5501 8 104 5 2 3 6 2 4 5 2 3 6 2 9 8 2 4 2 1 3 7 2 4 8 2 8 1 290 3 1 1 12 12 6 1 2 1 2 2 1 1 2 1 2 4 6 1 1 1 2 5 6 1 4 4 1 4 6 2 4 6 2 5 4 2 5 4 1 4 5 334 1 1 4 1 2 3 4 2 1 5 1 1 2 1 2 13 218 5 2 3 5 1 4 1 2 1 1 2 5 3 2 2 1 1 3 4 2 2 1 2 5 2 2 1 2 1 5 3 2 1 5 2 1 1 1 4 10 260 7 2 1 5 1 1 5 2 4 6 1 6...