코딩테스트 128
-
-
문제 풀이#include using namespace std;int n, input, y_total, m_total;int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i > input; // 각 통화 시간에 대해 영식 요금제와 민식 요금제를 개별적으로 계산 y_total += (input / 30 + 1) * 10; // 영식 요금제 요금 계산 m_total += (input / 60 + 1) * 15; // 민식 요금제 요금 계산 } if (y_total 메모각 통화 시간에 대해서 2개의 요금제에 대해서 개별적으로 요금을 계산해야 한다는 점..
-
문제 문제풀이#include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); int number = 0, minValue = 0; int sum = 0; vector odds; for (int i = 0; i > number; if (number % 2 == 1) { odds.push_back(number); sum += number; } } if (sum == 0) { sum = -1; cout 더 간결한 풀이 (출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x02/sol..
-
문제 풀이#include using namespace std;int main(){ ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); int input = 0; for (int i = 0; i > input; if (input == 0) { cnt++; } } switch (cnt) { case 0: cout 더 나은 풀이 (출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x02/solutions/2490.cpp)// Authored by : wogha95// Co-authored by : BaaaaaaaaaaarkingDog// http://boj.kr/..
-
-
-
문제 답안- vector, sort를 쓴 경우#include #include #include using namespace std;vector arr;int input;int main(){ ios::sync_with_stdio(0); cin.tie(0); for (int i = 0; i > input; arr.push_back(input); } sort(arr.begin(), arr.end()); for (int i = 0; i - swap으로 직접 정렬#include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int arr[3] = { 0, }; for (int i = 0; i > arr..
-
문제 풀이#include #include using namespace std;int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); deque dq; int n = 0, command = 0, input = 0; cin >> n; for (int i = 0; i > command; switch (command) { case 1: cin >> input; dq.push_front(input); break; case 2: cin >> input; dq.push_back(input); break; case 3: if (false == dq.empty()) { cout 메모가볍게 덱을 사용해..