QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225239 | #6708. Elevator Stopping Plan | Echo# | AC ✓ | 0ms | 1608kb | C++20 | 1.3kb | 2023-10-24 11:15:44 | 2023-10-24 11:15:44 |
Judging History
answer
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 35
int T, top, st;
int fl[N], stop[N];
int check(int mid)
{
int i, j, temp;
st = 0;
for (i=mid/20+2;i<=top;i++)
{
while (!fl[i] && i<top)
{
i++;
}
temp = (i-1)*4 + st*10;
if (temp>mid)
{
return 0;
}
j = (mid - 10*st + 20*i + 4)/24;
i = (mid - 10*st + 16*j + 4)/20;
stop[st++] = j;
}
return 1;
}
int elevator(int l, int r)
{
int mid;
while (l<r)
{
mid = (l+r)/2;
if (check(mid))
{
r = mid;
}
else
{
l = mid + 1;
}
}
return r;
}
int main()
{
int i, max, t, temp;
while (scanf("%d",&T) && T)
{
for (i=0;i<N;i++)
{
fl[i] = 0;
}
for (i=0;i<T;i++)
{
scanf("%d",&t);
fl[t] = 1;
top = t;
}
max = (top-1)*20;
temp = elevator(0,max);
printf("%d\n",temp);
check(temp);
printf("%d ",st);
for (i=0;i<st;i++)
{
printf("%d%c",stop[i],i==st-1 ? '\n':' ');
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 1524kb
input:
3 4 5 10 1 2 0
output:
46 2 5 10 4 1 2
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 1608kb
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 13 31 86 2 12 20 130 2 18 31 126 2 13 30 28 2 3 5 60 3 8 10 11 90 3 14 16 18 122 3 21 24 26 80 3 8 13 16 142 3 13 29 31 130 2 12 31 146 4 14 22 27 30 152 4 14 23 28 31 156 5 14 23 27 29 30 160 5 15 23 28 30 31
result:
ok correct (21 test cases)