QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720228 | #7744. Elevator | OIer_kzc# | WA | 37ms | 2800kb | C++17 | 1.3kb | 2024-11-07 11:17:41 | 2024-11-07 11:17:41 |
Judging History
answer
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#define LOG(FMT...) fprintf(stderr, FMT)
#define eb emplace_back
using namespace std;
typedef long long LL;
constexpr int N = 100005;
int n; LL m, res;
struct Good {
int c, w, f;
bool operator < (const Good &t) const {
return f < t.f;
}
} a[N];
LL cnt1, remain;
void work1(int cnt, int cost) {
assert(remain == 0ll && cnt1 == 0ll);
LL k = (cnt - 1) / m + 1;
res += cost * k;
remain = m * k - cnt;
}
void work2(int cnt, int cost) {
assert(remain == 0ll);
LL k = (cnt - 1) / (m / 2) + 1;
res += cost * k;
remain = m * k - 2 * cnt;
}
int main() {
int task;
for (scanf("%d", &task); task--; ) {
scanf("%d%lld", &n, &m);
for (int i = 0; i < n; ++i) {
auto &[c, w, f] = a[i];
scanf("%d%d%d", &c, &w, &f);
}
sort(a, a + n);
res = 0ll;
for (int i = n - 1; ~i; --i) {
auto &[c, w, f] = a[i];
LL t = min((LL)c, remain / w);
remain -= t * w;
c -= t;
if (remain == 1) {
cnt1 += 1;
remain = 0ll;
}
if (w == 1) {
t = min((LL)c, cnt1);
c -= t;
cnt1 -= t;
}
if (!c) {
continue;
}
(w == 1 ? work1 : work2)(c, f);
}
printf("%lld\n", res);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1656kb
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
Wrong Answer
time: 37ms
memory: 2800kb
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...
output:
9 0 20 2 0 0 0 0 0 0 1 0 0 9 0 2 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 1 0 8 0 0 0 7 0 0 0 1 0 0 5 0 0 3 4 0 0 0 9 0 0 0 0 0 0 0 5 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 6 0 5 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 4 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 3 0 4 0 0 0 0 4 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 1...
result:
wrong answer 2nd lines differ - expected: '1', found: '0'