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
- 유니티
- Team Fortress 2
- 스택
- 자료구조
- 시뮬레이션
- 그래프
- c++
- 트리
- BFS
- XR Interaction Toolkit
- 문자열
- Unreal Engine 5
- 백트래킹
- 투 포인터
- 그리디 알고리즘
- 정렬
- 유니온 파인드
- 누적 합
- 구현
- 재귀
- 백준
- 알고리즘
- DFS
Archives
- Today
- Total
1일1알
백준 7795번 먹을 것인가 먹힐 것인가 C++ 본문
https://www.acmicpc.net/problem/7795
7795번: 먹을 것인가 먹힐 것인가
심해에는 두 종류의 생명체 A와 B가 존재한다. A는 B를 먹는다. A는 자기보다 크기가 작은 먹이만 먹을 수 있다. 예를 들어, A의 크기가 {8, 1, 7, 3, 1}이고, B의 크기가 {3, 6, 1}인 경우에 A가 B를 먹을
www.acmicpc.net
이분탐색
#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>
using namespace std;
using int64 = long long;
int t;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<int> a(n);
vector<int> b(m);
int cnt = 0;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
sort(b.begin(), b.end());
for (int i = 0; i < n; i++) {
cnt += lower_bound(b.begin(), b.end(), a[i]) - b.begin();
}
cout << cnt << "\n";
}
}
'알고리즘' 카테고리의 다른 글
백준 16398번 행성 연결 C++ (0) | 2023.03.07 |
---|---|
백준 1411번 비슷한 단어 C++ (0) | 2023.03.05 |
백준 22233번 가희와 키워드 C++ (0) | 2023.03.03 |
백준 2942번 퍼거슨과 사과 C++ (0) | 2023.03.02 |
백준 20208번 진우의 민트초코우유 C++ (0) | 2023.03.01 |