# F. Sorting (排序，浮点数精度) [2017 CCPC China-Hunan Invitional]

## Description

Bobo has $n$tuples$(a_1, b_1, c_1), (a_2, b_2, c_2), \dots, (a_n, b_n, c_n)$ .
He would like to find the lexicographically smallest permutation $p_1, p_2, \dots, p_n$of$1, 2, \dots, n$ such that for$i \in \{2, 3, \dots, n\}$ it holds that

$\frac{a_{p_{i - 1}} + b_{p_{i - 1}}}{a_{p_{i - 1}} + b_{p_{i - 1}} + c_{p_{i - 1}}} \leq \frac{a_{p_i} + b_{p_i}}{a_{p_i} + b_{p_i} + c_{p_i}}$

### Input

The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer $n$.

The $i$-th of the following $n$lines contains $3$integers $a_i$,$b_i$ and$c_i$.

### Output

For each test case, print $n$integers$p_1, p_2, \dots, p_n$ seperated by spaces.
DO NOT print trailing spaces.

#### Constraint

• $1 \leq n \leq 10^3$
• $1 \leq a_i, b_i, c_i \leq 2 \times 10^9$
• The sum of $n$does not exceed$10^4$.

## 题解

### 分析

$(a_{p_{i-1}}+b_{p_{i-1}})(a_{p_{i}}+b_{p_{i}}+c_{p_{i}}) \leq (a_{p_{i}} + b_{p_{i}})(a_{p_{i-1}}+b_{p_{i-1}}+c_{p_{i-1}}))$

$(a_{p_{i-1}} + b_{p_{i-1}})c_{p_{i}} \leq (a_{p_{i}} + b_{p_{i}})c_{p_{i-1}}$

# A.队列Q - WannyFly挑战赛19

## 题目

64bit IO Format: %lld

### 题目描述

ZZT 创造了一个队列 Q。这个队列包含了 N 个元素，队列中的第 i 个元素用 Qi 表示。Q1 表示队头元素，QN 表示队尾元素。队列中的元素是 N 的一个全排列。
ZZT 需要在这个队列上执行 P 次操作，操作分两种：
FIRST X: 将元素 X 移到队头。
LAST X: 将元素 X 移到队尾。

# 题目

Problem Description

Given a sequence a[1],a[2],a[3]…a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.

# 枚举策略的基本思想

1. 在问题所有可能解之集合中一一枚举所有可能元素。
2. 以问题所给检验条件判断每个元素的状态（符合或不符合检验条件），符合条件的元素构成问题的解集。

# 题目

Problem Description

Input

Output

Sample Input

abcdefgfedcba
xxxxx


Sample Output

abcdefg(max)fedcba
x(max)x(max)x(max)x(max)x(max)