QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#351513 | #2375. Life Transfer | spiros_gal | WA | 1ms | 3592kb | C++14 | 2.0kb | 2024-03-11 23:59:12 | 2024-03-11 23:59:12 |
Judging History
answer
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long lc, pc, lm, pm;
long long t, d;
vector <long long> a;
vector <long long> disp;
vector <long long> dispc;
vector <long long> dispm;
vector <long long> needc;
vector <long long> needm;
bool can;
void printv(vector <long long> &v) {
for(auto u : v) {
cout << u << " ";
}
cout << endl;
}
int main() {
cin >> n >> k;
cin >> lc >> pc >> lm >> pm;
cin >> t >> d;
a.resize(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
disp.resize(n + 1);
dispc.resize(n + 1);
dispm.resize(n + 1);
needc.resize(n + 1);
needm.resize(n + 1);
can = false;
for(int i = 0; i < n; i++) {
disp[i + 1] = disp[i];
disp[i + 1] += min(a[i] - 1, d);
dispc[i + 1] = dispc[i];
needc[i + 1] = needc[i];
if(a[i] < lc) needc[i + 1] += lc - a[i];
else dispc[i + 1] += min(a[i] - lc, d);
dispm[i + 1] = dispm[i];
needm[i + 1] = needm[i];
if(a[i] < lm) needm[i + 1] += lm - a[i];
else dispm[i + 1] += min(a[i] - lm, d);
}
printv(a);
printv(disp);
printv(dispc);
printv(dispm);
printv(needc);
printv(needm);
long long currmin = LLONG_MAX;
for(int i = 0; i * k <= n; i++) {
long long cost = ((long long)i) * pc + ((long long) n - i * k) * pm;
long long disp_total = disp[i * k - i] - disp[0];
long long need_total = 0;
int cntm = n - i * k;
disp_total += dispm[n - i] - dispm[i * k - i];
disp_total += dispc[n] - dispc[n - i];
need_total += needm[n - i] - needm[i * k - i];
need_total += needc[n] - needc[n - i];
cout << "i=" << i << " disp_total=" << disp_total << " need_total=" << need_total << endl;
if(i && (a[n - i] < lc - d)) continue;
if(cntm && (a[i * k - i] < lm - d)) continue;
if(need_total > disp_total) continue;
can = true;
cost += need_total * t;
currmin = min(currmin, cost);
}
cout << ((can) ? currmin : -1) << endl;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3592kb
input:
2 2 18 1000 16 1 5 3 16 15
output:
15 16 0 3 6 0 0 0 0 0 0 0 3 5 0 1 1 i=0 disp_total=0 need_total=1 i=1 disp_total=3 need_total=2 1010
result:
wrong answer 1st lines differ - expected: '1010', found: '15 16 '