QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#771420 | #8057. Best Carry Player 4 | Tomorrow# | WA | 44ms | 3856kb | C++17 | 1.8kb | 2024-11-22 12:44:25 | 2024-11-22 12:44:26 |
Judging History
answer
#include <bits/extc++.h>
using namespace std;
#define C const
#define CE constexpr
#define TL template
#define TN typename
#define OP operator
#define pb push_back
#define ft first
#define sd second
#define mi (l+(r-l)/2)
#define TTT TL<TN T>
#define BE(v) v.begin(), v.end()
#define U unsigned
#define VD void
#define I int
#define LL long long
#define D double
using STR = string;
using PII = pair<I, I>;
TTT using V = vector<T>;
#define FORX(v) for(auto& x:v)
#define FOR(i,b,e) for(I i = b, _e = e;i<_e;++i)
#define FORR(i,b,e) for(I i = b, _e = e;i>_e;--i)
#define FUNC(T,f,...) function<T(__VA_ARGS__)> f = [&](__VA_ARGS__)->T
TTT VD setmin(T& a, C T& b){if(b<a)a=b;}
TTT VD setmax(T& a, C T& b){if(a<b)a=b;}
VD test()
{
I m; cin>>m;
V<I> a(m), b(m);
FORX(a)cin>>x;
FORX(b)cin>>x;
a[0] = 1e9, b[0] = 1e9;
I l = 0, r = m-1;
LL cnt[2] = {0,0};
I mxl = -1e9, mxr = -1e9;
while(l<m&&r>=0)
{
I num = min(a[l], b[r]);
if(num)setmax(mxr,r), setmax(mxl,l);
a[l]-=num; b[r]-=num;
cnt[l+r>=m]+=num;
if(a[l]==0)++l;
else if(b[r]==0)
{
--r;
if(l+r<m-1)++l;
}
}
if(cnt[1])
{
cout<<cnt[0]+cnt[1]<<'\n';
}
else
{
I mxa = -1e9;
FOR(i,0,m)if(a[i]>0)setmax(mxa, i);
if(mxa+mxr>=m)cout<<cnt[0]<<'\n';
else if(mxl+mxr>=m)cout<<cnt[0] - 1<<'\n';
else cout<<"0\n";
}
}
I main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen("test.in","r"))
{
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
}
I t = 1;
cin >> t;
while(t--)test();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
5 2 1 2 3 4 3 1 0 1 0 1 0 4 1 0 0 1 1 1 1 1 5 123456 114514 1919810 233333 234567 20050815 998244353 0 0 0 10 5 3 5 3 2 4 2 4 1 5 9 9 8 2 4 4 3 5 3 0
output:
5 1 2 467900 29
result:
ok 5 number(s): "5 1 2 467900 29"
Test #2:
score: -100
Wrong Answer
time: 44ms
memory: 3856kb
input:
100000 5 0 1 1 1 1 0 0 1 0 0 5 0 0 0 0 0 1 1 1 0 0 5 0 0 2 1 1 0 2 1 0 1 5 0 0 0 0 0 1 2 1 0 0 5 0 1 0 1 1 0 0 1 1 1 5 2 0 0 0 1 1 0 0 0 3 5 2 0 0 1 1 0 2 1 1 1 5 0 0 0 0 2 0 0 0 0 1 5 0 0 0 0 0 0 1 1 0 0 5 4 0 0 0 0 0 0 0 1 0 5 0 0 0 0 1 2 1 1 0 0 5 0 2 3 0 0 0 0 0 1 0 5 1 1 1 0 1 1 0 1 0 1 5 0 0 0...
output:
2 0 4 0 4 3 3 2 0 0 1 1 3 0 3 0 0 0 0 0 0 0 4 0 4 1 0 2 4 3 1 5 0 0 2 0 0 1 1 0 0 3 5 3 2 2 2 0 1 2 2 2 0 4 0 2 1 1 0 1 0 4 0 0 2 2 0 3 3 0 2 0 1 0 0 1 1 2 0 3 4 0 2 5 0 2 1 0 0 0 3 2 3 0 2 0 4 3 3 0 2 2 0 1 3 1 1 0 0 0 1 0 3 2 2 0 2 1 1 0 1 0 0 2 4 1 3 3 2 2 2 0 2 0 0 2 3 1 3 1 0 2 2 3 0 1 2 0 1 1 ...
result:
wrong answer 5th numbers differ - expected: '3', found: '4'