forked from derekhh/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicecream-parlor.cpp
More file actions
51 lines (48 loc) · 748 Bytes
/
icecream-parlor.cpp
File metadata and controls
51 lines (48 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//icecream-parlor.cpp
//Ice Cream Parlor
//Author: derekhh
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v[10001];
int main()
{
int t;
cin >> t;
while (t--)
{
int m;
cin >> m;
int n;
cin >> n;
for (int i = 1; i <= 10000; i++)
v[i].clear();
for (int i = 1; i <= n; i++)
{
int num;
cin >> num;
v[num].push_back(i);
}
for (int i = 1; i <= 10000; i++)
{
if (i != m - i)
{
if (!v[i].empty() && !v[m - i].empty())
{
cout << min(v[i][0], v[m - i][0]) << " " << max(v[i][0], v[m - i][0]) << endl;
break;
}
}
else
{
if (v[i].size() >= 2)
{
cout << v[i][0] << " " << v[i][1] << endl;
break;
}
}
}
}
return 0;
}