QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#380519 | #8057. Best Carry Player 4 | pope# | WA | 67ms | 3868kb | C++14 | 2.2kb | 2024-04-07 05:20:10 | 2024-04-07 05:20:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef vector<int> vi;
#define trav(a, x) for (auto& a: x)
#define f first
#define s second
#define pb push_back
const char nl = '\n';
#ifdef DBG
void dbg_out() { cerr << nl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
cerr << ' ' << H;
dbg_out(T...);
}
#define dbg(...) dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int t; cin >> t;
while (t--) {
int m; cin >> m;
int a[m], b[m];
rep(i, 0, m) cin >> a[i];
rep(i, 0, m) cin >> b[i];
a[0] = b[0] = 1e15;
// try all m options for which one adds to 10+
// with 2 ptr
// now we want the k-1 sums to >= m-1
int leftover = 0;
int ans = 0;
bool ok = 0;
vector<int> remA(m);
vector<int> remB(m);
for(int i = 0; i<m; i++){
remA[i] = a[i];
remB[i] = b[i];
}
rep(i, 0, m) {
int cur = min(a[i], leftover+b[m-1-i]);
// take from leftover first
if (leftover > 0 && a[i] > 0) {
ok = 1;
}
ans += cur;
remA[i] -= cur;
remB[m-1-i] -= cur;
leftover = leftover+b[m-1-i]-cur;
}
int bigA = 0;
int bigB = 0;
for(int i = 0; i<m; i++){
if(a[i]>0){
bigA = i;
}
if(b[i]>0){
bigB = i;
}
}
for(int i = 0; i<m; i++){
if(remA[i]>0 && i+bigB>=m){
ok = 1;
}
if(remB[i]>0 && i+bigA>=m){
ok = 1;
}
}
if(!ok){
ans--;
}
cout << ans << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3652kb
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: 67ms
memory: 3868kb
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 -1 4 -1 4 3 3 2 -1 -1 1 1 3 0 3 0 0 -1 -1 0 0 0 4 0 4 1 -1 2 4 3 1 5 0 -1 2 0 0 1 1 -1 0 3 5 3 2 2 2 -1 1 2 2 2 -1 4 0 2 1 1 0 1 -1 4 1 1 2 2 -1 3 3 -1 2 -1 1 -1 0 1 1 2 0 3 4 -1 2 5 -1 2 1 0 0 -1 3 2 3 -1 2 0 4 3 3 0 2 2 1 1 3 1 1 -1 0 -1 1 -1 3 2 2 -1 2 1 1 0 1 -1 0 2 4 1 3 3 2 2 2 -1 2 -1 0 2 3...
result:
wrong answer 2nd numbers differ - expected: '0', found: '-1'