알고리즘(139)
-
[백준 14888번] 연산자 끼워넣기
소스코드12345678910111213141516171819202122232425#include using namespace std; int n, num[101], cal[4];long long Max=-1000000000,Min=1000000000; void ret(int a, int b, int c, int d,int depth, long long sum) { if (depth == n-1) { if (Max sum) { Min = sum; } } if (a > 0) { ret(a - 1, b, c, d, depth + 1, sum + num[depth + 1]); } if (b > 0) { ret(a, b-1, c, d, depth + 1, sum - num[depth + 1]); } if (c >..
2017.11.27 -
[백준 3020번] 개똥벌레
소스코드1234567891011121314151617181920212223242526272829303132#include using namespace std; int a[500001], b[500001]; int main() { int aMax = 0, bMax = 0; int n, h, Min=987654321,tmp,cnt=1; cin >> n >> h; for (int i = 0; i > inputA >> inputB; a[inputA]++; b[inputB]++; if (aMax = 1; i--) b[i] += b[i + 1]; for (int i = 1; i
2017.10.18 -
[백준 3079번] 입국심사
소스코드123456789101112131415161718192021222324#include using namespace std; #define MAX 100000000000000 int main() { int n; long long m, t[100001], left=1,right=MAX,result=MAX; cin >> n >> m; for (int i = 0; i > t[i]; while (left mid) { result = mid; } right = mid - 1; } else if (sum
2017.10.18 -
[백준 13305번] 주유소
소스코드123456789101112131415161718#include using namespace std; int main() { int n, dist[100001], prev = 1000000001; long long result=0; cin >> n; for (int i = 0; i > dist[i]; for (int i = 0; i > a; prev = (prev > a ? a : prev); result += (i!=n-1?prev*dist[i]:0); } cout
2017.10.18 -
[백준 14501번] 퇴사
소스코드123456789101112131415161718192021222324#include using namespace std; int n, a[2][16],num[16], Max=0; void cal(int idx, int sum) { if (idx == n+1) { Max = (Max a[0][i] >> a[1][i]; cal(1, 0); cout
2017.10.18 -
[백준 2805번] 나무 자르기
소스코드1234567891011121314151617181920212223242526#include using namespace std; int main() { long long n, m, num[1000001], Max = -1, left = 1, right = 1000000000; cin >> n >> m; for (int i = 0; i > num[i]; while (left= m) { left = mid+1; if (mid > Max) Max = mid; } else { right = mid-1; } } cout
2017.10.17