G. 两数之和

    Type: Default 1000ms 256MiB

两数之和

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

翻译自 CSES-1640 题。

题目描述

给你一个由 nn 个整数组成的数组,你的任务是找出两个数(在不同的位置)的和为 xx

输入格式

第一行输入两个整数 nnxx,分别代表数组大小和目标和。

第二行有 nn 个整数 a1,a2,,ana_1,a_2,…,a_n,分别代表数组值。

输出格式

输出两个整数:分别表示两个数的下标位置。如果有多个解,可以输出任意一组解。如果没有解,则输出 1-1

样例

4 8
2 7 5 1
2 4

说明/提示

2n21052 \leq n \leq 2\cdot 10^5

1x,ai1091 \leq x,a_i\leq 10^9

CSES练习二 排序贪心STL

Not Claimed
Status
Done
Problem
35
Open Since
2025-5-1 0:00
Deadline
2025-5-31 23:59
Extension
24 hour(s)