MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CSES/Sorting/SumOfTwoValues.cc:6–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#define rep(i,a,b) for(int i=a; i < (b); ++i)
5
6int main(){
7 ios_base::sync_with_stdio(false),cin.tie(nullptr);
8
9 int n, x; cin >> n >> x;
10 map<int,int>m;
11 vector<int> V;
12 rep(i,0,n){
13 int v; cin >> v;
14 V.push_back(v);
15 m[v] = i;
16 }
17
18 rep(i,0,n) {
19 if (m.find(x - V[i]) != m.end() && m[x-V[i]]!=i) {
20 cout << i+ 1 << " " << m[x-V[i]] + 1 << endl;
21 exit(0);
22 }
23 }
24 cout << "IMPOSSIBLE" << endl;
25 return 0;
26}
27
28

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected