QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225225 | #6708. Elevator Stopping Plan | Echo# | WA | 0ms | 3884kb | C++20 | 1.3kb | 2023-10-24 10:08:27 | 2023-10-24 10:08:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[50];
int a[50];
int walk_time(int x, int y) {
return abs(x-y)*20;
}
int ele_time(int x, int y) {
return abs(x-y)*4;
}
bool check(int mx, vector<int> &vec)
{
vec.clear();
vector<pair<int, int>> q;
int tmp;
q.push_back({1, 0});
for (int i=1; i<=m; i++) {
auto [x, t] = q.back();
tmp = walk_time(a[i], x);
if (tmp <= mx) continue;
q.push_back({a[i], t+(x==1 ? 0 : 10)+ele_time(x, a[i])});
vec.push_back(a[i]);
}
return q.back().second <= mx;
}
bool solve()
{
memset(cnt, 0, sizeof(cnt));
scanf("%d", &n);
if (n == 0) return false;
m = 0;
for (int i=1, v; i<=n; i++) scanf("%d", &v), cnt[v]++;
for (int i=2; i<=31; i++) if (cnt[i]) a[++m] = i;;
int ans = 1e9;
vector<int> ansvec, tmpvec;
int L, R, M;
for (L=(a[m]-1)*4, R=500; L <= R; ) {
M = (L+R)/2;
if (check(M, tmpvec)) {
ans = M;
ansvec = tmpvec;
R = M-1;
}
else {
L = M+1;
}
}
printf("%d\n%ld", ans, ansvec.size());
for (int x: ansvec) printf(" %d", x);
puts("");
return true;
}
int main()
{
while (solve())
;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
3 4 5 10 1 2 0
output:
46 2 4 10 4 1 2
result:
ok correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3884kb
input:
1 2 1 10 1 20 1 31 2 2 10 2 2 31 2 10 31 2 10 20 3 2 15 31 3 2 10 30 4 2 3 4 5 5 7 8 9 10 11 6 13 14 15 16 17 18 7 20 21 22 23 24 25 26 8 2 4 6 8 10 12 14 16 10 2 3 4 9 10 11 28 29 30 31 10 2 3 4 5 6 7 8 9 10 31 15 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 15 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 ...
output:
4 1 2 36 1 10 76 1 20 120 1 31 36 1 10 120 1 31 130 2 10 31 86 2 10 20 130 2 15 31 126 2 10 30 26 2 3 5 46 2 7 10 74 2 13 17 110 2 20 26 72 3 6 10 14 120 2 9 28 130 2 8 31 120 3 8 16 24 120 3 9 17 25 128 3 8 21 28 140 3 9 17 25
result:
wrong answer (test case 11)