In this HackerEarth Providing gifts problem solution, You are given N coins whose values are from 1 to N. The value of each coin ranges from 1 to N. You want to gift as many people as you can.
You also want to be fair with everyone and therefore, you prepare the gift such that each person can be gifted the same amount of money. You are allowed to put several denominations together in a gift. What is the maximum number of gifts that you can prepare?
Note: It does not make sense to prepare empty gifts.
HackerEarth Providing gifts problem solution.
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define endl "n"
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
FIO;
test
{
ll n;
cin>>n;
++n;
n/=2;
cout<<n<<endl;
}
return 0;
}
Second solution
t = int(input())
while t > 0:
t -= 1
n = int(input())
print((n + 1) // 2)