CF31A.Worms Evolution

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are n forms of worms. Worms of these forms have lengths _a_1, _a_2, ..., a__n. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to sum of lengths of the other two forms. Help him to do this.

瓦谢金教授正在研究蠕虫的进化。最近,他提出了一个假说:所有蠕虫都通过分裂而进化。目前已知存在 nn 种蠕虫形态,这些形态的蠕虫长度分别为 a1,a2,…,ana_1, a_2, \dots, a_n。为了验证该理论,教授需要找出三种互不相同的形态,使得其中一种形态的长度等于另外两种形态长度之和。请帮助他完成这一任务。

输入格式

The first line contains integer n (3 ≤ n ≤ 100) — amount of worm's forms. The second line contains n space-separated integers a__i (1 ≤ a__i ≤ 1000) — lengths of worms of each form.

第一行包含一个整数 nn(3≤n≤1003 \leq n \leq 100)—— 虫子形态的数量。
第二行包含 nn 个用空格分隔的整数 aia_i(1≤ai≤10001 \leq a_i \leq 1000)—— 每种形态下虫子的长度。

输出格式

Output 3 distinct integers i j k (1 ≤ i, j, k ≤ n) — such indexes of worm's forms that a__i = a__j + a__k. If there is no such triple, output -1. If there are several solutions, output any of them. It possible that a__j = a__k.

输出三个互不相同的整数 ii、jj、kk(满足 1 ≤ i, j, k ≤ n1 \le i,\,j,\,k \le n),使得蠕虫的这三种形态满足 ai=aj+aka_i = a_j + a_k。若不存在这样的三元组,则输出 −1-1。若存在多个解,输出任意一个即可。注意,允许 aj=aka_j = a_k。

输入输出样例

  • 输入#1

    5
    1 2 3 5 7

    输出#1

    3 2 1
  • 输入#2

    5
    1 8 1 5 1

    输出#2

    -1

输入解题思路,AI测评打分。不知道怎么写?

首页