본문 바로가기

BOJ/C++

(202)
사탕상자 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 #include #include #include #define MAXX 1000001 using namespace std; typedef long long ll; int tree_h; int ret = 0; void update(vector &tree, int node, int diff, int idx, in..
보석도둑 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 //보석도둑 #include #include #include #include #define MAXX 300001 using namespace std; typedef long long ll; int n, k; typedef pair pp; bool compare(const pp &a, const pp &b) { if (a.first > b.first) return..
커피숍2 관련문제 2020/02/14 - [BOJ/C++] - 구간 합 구하기 불러오는 중입니다... 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #include #include #include using namespace std; typedef long long ll; void update(vector &tree, int node, ll diff, int idx, int start..
가운데를 말해요 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 29 30 31 32 33 34 35 36 37 #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector nums; vector :: iterator it; for (int i = 0; i > input; it = lower_bound(nums.begin(), nums.end(), input); nums.insert(it, input); if ((i+1) % 2) { //홀수개일때 cout
구간 합 구하기 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 //구간 합 구하기 #include #include #include #define MAXX 1000001 using namespace std; typedef long long ..
카드게임 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 #include #include #include #define MAXX 1001 using namespace std; int dp[MAXX][MAXX]; int card[MAXX] = { 0 }; // int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n..
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #include #include #define MAXX 101 #define MAXM 100*100+1 using namespace std; int dp[MAXM]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; //앱의 수, 확보해야하는 메모리 양 int mem[MAXX] = { 0 }, cost[MAXX] = { 0 }; int total = 0; for (int i = 0; i > mem[i..
Dance Dance Revolution #include #include #include #define INF 987654321 #define MAXX 100001 using namespace std; typedef pair pp; int direc[MAXX] = { 0 }; int idx = 0; int dp[MAXX][5][5]; int move(int now, int prev) { if (!prev) return 2; else if (now == prev) return 1; else if (abs(now - prev)==2) return 4; else return 3; } int dfs(int cnt, int left, int right) { if (cnt == idx) { int lRes = move(direc[cnt], left); i..