#CCBCHBON0000030. Tìm cặp (i,j) đầu tiên (First Pair with Given Sum)
Tìm cặp (i,j) đầu tiên (First Pair with Given Sum)
First Pair with Given Sum
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Consider pairs 1<=i<j<=n in lexicographic order (i increasing, then j increasing). Print the first pair whose sum is k, or -1 if absent. An equal-index pair is invalid.
Input
One line: ; , .
Output
Print i j separated by a space, or -1.
Subtasks
-
Subtask 1 (20%): ; .
-
Subtask 2 (30%): ; .
-
Subtask 3 (50%): ; .
Examples
Example 1
Input:
5 6
Output:
1 5
Explanation:
The first pair in lexicographic order meeting i<j and i+j=k is printed; otherwise -1. Result: 1 5.
Example 2
Input:
3 2
Output:
-1
Explanation:
The first pair in lexicographic order meeting i<j and i+j=k is printed; otherwise -1. Result: -1.
Example 3
Input:
1 2
Output:
-1
Explanation:
The first pair in lexicographic order meeting i<j and i+j=k is printed; otherwise -1. Result: -1.