QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#100456 | #6130. Plants vs. Zombies | maomao90# | WA | 156ms | 5564kb | C++17 | 1.8kb | 2023-04-26 14:04:58 | 2023-04-26 14:04:59 |
Judging History
answer
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;
int t;
int n;
ll m;
int a[MAXN];
ll b[MAXN];
bool isPos(ll x) {
ll prv = 0;
ll res = n;
REP (i, 1, n + 1) {
b[i] = (x - 1) / a[i];
b[i] -= prv;
res += b[i] * 2;
if (res >= LINF) {
return 0;
}
prv = b[i];
}
RREP (i, n, 1) {
if (b[i] < 0) {
res--;
} else {
break;
}
}
return res <= m;
}
int main() {
#ifndef DEBUG
ios::sync_with_stdio(0), cin.tie(0);
#endif
cin >> t;
while (t--) {
cin >> n >> m;
REP (i, 1, n + 1) {
cin >> a[i];
}
ll lo = 0, hi = LINF, mid;
while (lo < hi) {
mid = lo + hi + 1 >> 1;
if (isPos(mid)) {
lo = mid;
} else {
hi = mid - 1;
}
}
cout << lo << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 5564kb
input:
2 4 8 3 2 6 6 3 9 10 10 1
output:
6 4
result:
ok 2 number(s): "6 4"
Test #2:
score: -100
Wrong Answer
time: 156ms
memory: 4516kb
input:
116 4 0 3 2 6 6 4 1 3 2 6 6 10 19 10 2 8 4 2 4 9 3 3 3 4 8 3 9 3 6 2 19 2 10 11 15 3 1 1 4 3 7 10 8 6 7 10 10 14 8 7 1 1 10 9 2 8 10 7 2 13 2 3 10 10 8 1 6 6 9 4 7 1 8 8 7 14 6 7 4 5 3 1 3 11 6 8 1 10 9 7 2 6 6 1 3 9 4 10 6 1 3 8 7 7 10 6 2 10 4 7 2 5 11 9 10 5 9 2 9 1 2 4 8 6 2 8 8 1 6 4 5 7 2 9 8 ...
output:
0 0 4 12 100 3 3 21 1 6 0 4 2 6 0 2 24 3 30 10 0 2 3 0 0 2 12 0 2 10 27 28 3 14 6 0 5 10 6 6 6 5 0 4 4 7 40 2 0 0 16 8 0 30 8 48 4 2 5 0 2 0 5 0 9 2 0 0 0 0 5 0 4 18 63 0 0 40 5 0 2 4 0 0 16 8 6 1 0 5 24 3 8 0 7 0 10 14 5 10 1 6 36 0 990 0 51 192 960 798 230 0 234 7591611 1000000000000 30515493408
result:
wrong answer 4th numbers differ - expected: '6', found: '12'