Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 구현
- 재귀
- 누적 합
- 다익스트라
- 자료구조
- 백트래킹
- ue5
- VR
- c++
- 투 포인터
- 알고리즘
- BFS
- 백준
- 문자열
- 유니티
- 그래프
- 스택
- 다이나믹 프로그래밍
- 시뮬레이션
- 그리디 알고리즘
- 브루트포스
- 수학
- DFS
- Unreal Engine 5
- 우선순위 큐
- 유니온 파인드
- XR Interaction Toolkit
- Team Fortress 2
- 트리
- 정렬
Archives
- Today
- Total
1일1알
백준 3273번 두 수의 합 C++ 본문
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
#include <bitset>
using namespace std;
using int64 = long long;
int n, x;
vector<int> v;
unordered_set<int> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
v = vector<int>(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
s.insert(v[i]);
}
cin >> x;
int cnt = 0;
for (int i = 0; i < n; i++) {
int target = x - v[i];
if (target == v[i]) continue;
if (target <= 0) continue;
auto it = s.find(target);
if (it == s.end()) continue;
cnt++;
s.erase(v[i]);
}
cout << cnt;
}
'알고리즘' 카테고리의 다른 글
백준 25307번 시루의 백화점 구경 C++ (0) | 2022.09.17 |
---|---|
백준 19238번 스타트 택시 C++ (0) | 2022.09.16 |
백준 2437번 저울 C++ (1) | 2022.09.14 |
백준 1939번 중량제한 C++ (0) | 2022.09.13 |
백준 17478번 재귀함수가 뭔가요? C++ (0) | 2022.09.12 |