티스토리 뷰
백준 소스코드 [C++] 2467 용액
#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <limits.h>
#include <vector>
#include <math.h>
#include <stack>
#include <bitset>
#include <string>
#include <set>
#define all(v) v.begin(), v.end()
#define pii pair<int,int>
#define make_unique(v) v.erase(unique(v.begin(), v.end()), v.end())
typedef long long ll;
using namespace std;
int n;
vector<int> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n; v.resize(n+1);
for (int i = 1;i <= n;i++) cin >> v[i];
int L = 1, R = n, here=abs(v[L]+v[R]),there;
int l = 1, r = n;
while (L<R) {
there = v[L] + v[R];
if (here > abs(there)) {
here = abs(there);
l = L, r = R;
}
if (there < 0) L++;
else R--;
}
cout << v[l] << " " << v[r];
return 0;
}
'백준' 카테고리의 다른 글
백준 소스코드 [C++] 14921 용액 합성하기 (0) | 2021.03.02 |
---|---|
백준 소스코드 [C++] 2470 두 용액 (0) | 2021.03.02 |
백준 소스코드 [C++] 12920 평범한 배낭 2 (0) | 2021.03.01 |
백준 소스코드 [C++] 2263 트리의 순회 (0) | 2021.03.01 |
백준 소스코드 [C++] 11478 서로 다른 부분 문자열의 개수 (0) | 2021.02.27 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- IOS
- 네트워크 플로우
- 벨만포드 알고리즘
- rxswift
- test coverage
- WWDC17
- 에드몬드 카프 알고리즘
- MeTal
- State Restoration
- CPU와 Memory
- mach-o
- 최단경로 문제
- 컴퓨터 추상화
- 부스트캠프 6기
- 최단경로 알고리즘
- 강한 순환 참조
- 다익스트라 시간복잡도
- observeOn
- WWDC21
- 벨만포드 시간복잡도
- WWDC19
- WWDC16
- 최단경로문제
- CompositionalLayout
- 네트워크 유량
- 포드 풀커슨 알고리즘
- 코딩대회
- Testable
- HIG
- 최대 매칭
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함