#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N; cin >> N;
vector<int>v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
sort(v.begin(), v.end()); //์ด๋ถํ์์ ์ํ ์ ๋ ฌ
int cnt = 0;
for (int i = 0; i < N; i++) {
int start = 0;
int end = N - 1;
while (start < end) {
if (v[start] + v[end] == v[i]) {
if (start != i && end != i) {
cnt++;
break;
}
else if (start == i) start++;
else if (end== i) end--;
}
else if (v[start] + v[end] < v[i]) start++;
else end--;
}
}
cout << cnt;
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 12605๋ฒ - ๋จ์ด ์์ ๋ค์ง๊ธฐ (0) | 2021.11.02 |
---|---|
[๋ฐฑ์ค,c++] 1260๋ฒ - DFS์ BFS (0) | 2021.11.02 |
[๋ฐฑ์ค,c++] 1259๋ฒ - ํฐ๋ฆฐ๋๋กฌ์ (0) | 2021.11.02 |
[๋ฐฑ์ค,c++] 1238๋ฒ - ํํฐ (0) | 2021.11.02 |
[๋ฐฑ์ค,c++] 12015๋ฒ - ๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ ์์ด2 (0) | 2021.11.02 |
[๋ฐฑ์ค,c++] 1197๋ฒ - ์ต์ ์คํจ๋ ํธ๋ฆฌ (0) | 2021.11.02 |
๋๊ธ