QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198018 | #6130. Plants vs. Zombies | HarryJ | Compile Error | / | / | C++23 | 1.4kb | 2023-10-02 23:39:48 | 2023-10-02 23:39:48 |
Judging History
answer
#include<stdio.h>
const int N = 1e5 + 5;
long long n, m, a[N];
bool A(long long x)
{
long long b[N] = {0};
long long i, k, z;
for(i = 0, k = m; i < n - 1; i++)
{
if(b[i] >= x)
{
if(k > 0)
k--;
else
return 0;
continue;
}
z = x - b[i];
if(z % a[i])
z = z / a[i] + 1;
else
z = z / a[i];
if(k < z * 2 - 1)
return false;
k -= z * 2 - 1;
b[i+1] += (z-1) * a[i+1];
}
if(b[i] < x)
{
z = x - b[i];
if(z % a[i])
z = z / a[i] + 1;
else
z = z / a[i];
if(k < z * 2 - 1)
return false;
}
return true;
}
int main()
{
long long t, i, x, r, l;
scanf("%lld", &t);
while(t--)
{
scanf("%lld%lld", &n, &m);
r = 1e17;
for(i = 0; i < n; i++)
{
scanf("%lld", &a[i]);
if(r > a[i] * m)
r = a[i] * m;
}
l = 0;
while(r - l > 1)
{
x = (r + l) / 2;
if(A(x))
l = x;
else
r = x;
}
if(A(r))
printf("%lld\n", r);
else
printf("%lld\n", l);
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:72:12: error: unable to find numeric literal operator ‘operator"";’ 72 | return 0; | ^~~ answer.code:72:12: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes answer.code:72:15: error: expected ‘;’ before ‘}’ token 72 | return 0; | ^ | ; 73 | } | ~ answer.code:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%lld", &t); | ~~~~~^~~~~~~~~~~~ answer.code:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%lld%lld", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~~~~~ answer.code:54:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | scanf("%lld", &a[i]); | ~~~~~^~~~~~~~~~~~~~~