QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#517090 | #6130. Plants vs. Zombies | Tahmid76 | WA | 1ms | 7756kb | C++14 | 2.0kb | 2024-08-13 06:01:04 | 2024-08-13 06:01:05 |
Judging History
answer
//And He found you lost and guided [you] [93:07]
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef map<int,int> mpi;
typedef map<ll,ll> mpl;
typedef unordered_map<int,int> umpi;
typedef unordered_map<ll,ll> umpl;
#define modu 998244353
#define mod 1000000007
#define eps 1e-9
#define inf 1000000000000000006
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
// #define pi acos(-1.0)
#define dec(n) fixed << setprecision(n)
#define N 300005
#define int long long
int n,m,a[N],c[N],cs[N];
int chk(int x){
int moves=0;
c[0]=0;
cs[0]=0;
if(x==0) return 1;
for(int i=1;i<=n;i++){
c[i]=(x+a[i]-1)/a[i];
c[i]--;
cs[i]=(cs[i-1]+c[i])!=0;
}
moves=n;
for(int i=n;i>0;i--){
moves+=max(0LL,c[i])*2+1;
c[i-1]-=(max(0LL,c[i])+1);
if(cs[i-1]==0){
moves--;
if(c[i]<0) moves--;
break;
}
}
cout << moves << " ";
return moves<=m;
}
void solve(){
cin >> n >> m;
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=0;i<=10;i++) cout << i << " -> " << chk(i) << endl;
int lo=0,hi=1e18,ans;
while(lo<=hi){
int mid=(lo+hi)/2;
if(chk(mid)){
ans=mid;
lo=mid+1;
}
else hi=mid-1;
}
cout << ans << endl;
}
signed main(){
fastio;
//srand(chrono::steady_clqk::now().time_since_epqh().count());
// fflush(stdout);
int T=1,cs=0;
cin >> T;
while(T--){
//cout << "Case " << ++cs << ": " ;
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7756kb
input:
2 4 8 3 2 6 6 3 9 10 10 1
output:
0 -> 1 1 -> 4 1 2 -> 4 1 3 -> 6 1 4 -> 7 1 5 -> 8 1 6 -> 8 1 7 -> 12 0 8 -> 12 0 9 -> 14 0 10 -> 14 0 666666666666666668 333333333333333334 166666666666666668 83333333333333334 41666666666666668 20833333333333334 10416666666666668 5208333333333334 2604166666666668 1302083333333...
result:
wrong answer 1st numbers differ - expected: '6', found: '0'