Codeforces Round #797 (Div. 3)

A. Print a Pedestal (Codeforces logo?)

题目:

Given the integer — the number of available blocks. You must use all blocks to build a pedestal.

The pedestal consists of platforms for 2-nd, 1-st and 3-rd places respectively. The platform for the 1-st place must be strictly higher than for the 2-nd place, and the platform for the 2-nd place must be strictly higher than for the 3-rd place. Also, the height of each platform must be greater than zero (that is, each platform must contain at least one block).

Example pedestal of n=11 blocks: second place height equals 4 blocks, first place height equals 5 blocks, third place height equals 2 blocks.

Among all possible pedestals of blocks, deduce one such that the platform height for the 1-st place minimum as possible. If there are several of them, output any of them.

Input

The first line of input data contains an integer t (1≤t≤e4) — the number of test cases.

Each test case contains a single integer n (6≤n≤e5) — the total number of blocks for the pedestal. All n blocks must be used.

It is guaranteed that the sum of values over all test cases does not exceed e6.

Output

For each test case, output 3 numbers h2,h1,h3 — the platform heights for 2-nd,  1-st and 3-rd places on a pedestal consisting of n blocks (h1+h2+h3=n, 0<h3<h2<h1).

Among all possible pedestals, output the one for which the value of h1 minimal. If there are several of them, output any of them.

Example

input

6
11
6
10
100000
7
8

output

4 5 2
2 3 1
4 5 1
33334 33335 33331
2 4 1
3 4 1

Note

In the first test case we can not get the height of the platform for the first place less than 5, because if the height of the platform for the first place is not more than 4, then we can use at most 4+3+2=9 blocks. And we should use 11=4+5+2 blocks. Therefore, the answer 4 5 2 fits.

In the second set, the only suitable answer is: 2 3 1.

翻译: 

题解:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int t,n;
	cin>>t;
	while(t--){
		cin>>n;
		cout<<n/3+(n%3>=2)<<" "<<n/3+(n%3>=1)+1<<" "<<n/3-1<<"\n";
	}
	return 0;
}

B. Array Decrements

题目:

翻译:

  

题解: 

for _ in range(int(input())):
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    m = 0;
    for i in range(n):
        m = max(m,a[i]-b[i])
    for i in range(n):
        a[i] = max(a[i]-m,0)
    print("YES" if a == b else "NO")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值