QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#843209 | #9961. Cows | ucup-team3586# | WA | 0ms | 3848kb | C++23 | 1.5kb | 2025-01-04 17:19:51 | 2025-01-04 17:19:51 |
Judging History
answer
#include<bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
#define int long long
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
int a[1<<20];
signed main()
{for(int T=1;T--;){
int n=read();
for(int i=1; i<=n; ++i) a[i]=read();
int l=0,r=1e9,ans=r+1;
// int l=2,r=2,ans=4;
while(l<=r)
{
int mid=(l+r)>>1;
int x=min(a[1],mid);
int y=max(0ll,a[1]-mid);
int z=mid;
int o=(a[1]<=mid);
// printf("%lld %lld %lld %lld %lld\n",1ll,x,y,z,o);
for(int i=2; i<=n; ++i)
{
if(o)
{
if(a[i]<=x)
{
x=a[i],y=0,z=mid;
}
else if(a[i]<=(z-y)*2-x)
{
x=(a[i]+x+1)/2,y=0,z=mid;
}
else if(a[i]<=(z-y)*2-x+y)
{
x=(a[i]-(z-y)*2+x)+(z-y),y=0,z=mid;
}
else if(a[i]<=mid*2-y-x)
{
// puts("qwq");
x=(a[i]+x+y+1)/2,y=0,z=mid;
}
else
{
// puts("owo");
y=a[i]-(mid*2-y-x),x=mid,o=0;
}
}
else
{
if(a[i]<=x-y)
{
z=x;
x=a[i];
o=1;
}
else
{
int oy=y;
y=a[i]-(x-y);
x-=oy;
}
}
// printf("%lld %lld %lld %lld %lld\n",i,x,y,z,o);
}
if(o) ans=mid,r=mid-1;
else l=mid+1;
}
printf("%lld\n",ans);
}return 0;}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
5 5 4 0 4 6
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
3 1 4 6
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
1 1000000000
output:
1000000000
result:
ok 1 number(s): "1000000000"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
8 6 0 5 5 6 3 0 6
output:
4
result:
ok 1 number(s): "4"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
6 7 6 5 2 6 8
output:
7
result:
ok 1 number(s): "7"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
10 5 9 3 4 3 2 5 8 2 3
output:
6
result:
ok 1 number(s): "6"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
10 1 18 3 15 0 14 20 15 14 12
output:
14
result:
ok 1 number(s): "14"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
10 1 18 3 15 0 14 20 15 15 12
output:
15
result:
ok 1 number(s): "15"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
20 97 171 3 157 117 35 0 0 173 154 59 58 18 189 27 181 78 20 253 22
output:
100
result:
ok 1 number(s): "100"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
20 96 171 3 157 117 35 0 0 173 154 59 58 18 188 27 181 78 20 253 22
output:
99
result:
ok 1 number(s): "99"
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 3848kb
input:
1000 593735308 82782684 48201198 606672331 542608382 778767270 477934211 44729051 264362294 224305033 653755557 885668853 118708751 883106152 840075111 736969436 245937442 943545017 520344248 725034355 640010480 177641398 4028045 527811023 508005025 452498275 65950769 521987921 497919638 401868301 4...
output:
374289135
result:
wrong answer 1st numbers differ - expected: '798545293', found: '374289135'