Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must solve in Java C. Number Game time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output

image text in transcribed

Must solve in Java

C. Number Game time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Alice and Bob are playing a game. They have an array of positive integers a of size n. Before starting the game, Alice chooses an integer k0. The game lasts for k stages, the stages are numbered from 1 to k. During the i th stage, Alice must remove an element from the array that is less than or equal to ki+1. After that, if the array is not empty, Bob must add ki+1 to an arbitrary element of the array. Note that both Alice's move and Bob's move are two parts of the same stage of the game. If Alice can't delete an element during some stage, she loses. If the k-th stage ends and Alice hasn't lost yet, she wins. Your task is to determine the maximum value of k such that Alice can win if both players play optimally. Bob plays against Alice, so he tries to make her lose the game, if it's possible. Input The first line contains a single integer t(1t100) - the number of test cases. The first line of each test case contains a single integer n(1n100) - the size of the array a. The second line contains n integers a1,a2,,an(1ain). Output For each test case, print one integer - the maximum value of k such that Alice can win if both players play optimally

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Draw the starting structure that would

Answered: 1 week ago

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago

Question

What is computer neworking ?

Answered: 1 week ago