일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Stack
- 정석학술정보관
- Computer science
- 코테
- coding
- 알고리즘
- vector
- 문제풀이
- 너비우선탐색
- 그래프
- Operating System
- 오퍼레이팅시스템
- 정석
- cs
- 백준
- 자료구조
- 컴공과
- DP
- OS
- 컴퓨터공학과
- 북리뷰
- bfs
- 브루트포스
- 구현
- 스택
- 컴공
- 개발
- c++
- 오에스
- 코딩
- Today
- Total
목록개발 (97)
Little Jay
이 문제는 시간제한이 있는 문제이다 처음에는 당연히 while 문을 써서 풀었는데 시간초과가 나왔다. 시간 복잡도를 생각하면 O(n)이 되어야 하니까 잘만 생각해보면 이런 알고리즘(?)으로 나타낼 수 있다. #include using namespace std; int main() { int a, b, v; cin >> a >> b >> v; int distance = 0; int day; if ((v - a) % (a - b) == 0) { day = (v - a) / (a - b); } else { day = (v - a) / (a - b) + 1; } cout
sort를 적절히 활용하는 문제 sort에서 compare함수를 조금 잘 정의해야할 것 같다 여기 부분때문에 3번정도 틀린 것 같다. 문제가 y 좌표를 기준으로 비교하고, y좌표가 같을때는 다시 x좌표를 기준으로 정렬해야되니까 이 부분 신경써서 코드를 작성해야한다. #include #include #include using namespace std; bool compare(const pair &a, const pair &b) { if (a.second < b.second) { return true; } else if (a.second == b.second) { if (a.first < b.first) return true; } return false; } int main() { int testCase; ..
#include #include #include using namespace std; int main() { ios::sync_with_stdio(false); int testCase; cin >> testCase; deque dq; for (int i = 0; i > s; if (s == "push_front") { int num; cin >> num; dq.push_front(num); } else if (s == "push_back") { int num; cin >> num; dq.push_back(num); } else if (s == "pop_front") { if (dq.empty()) { cout
일반적으로 벡터나 배열에 숫자를 저장하게 된다면 문제의 조건에서 주어진 메모리값을 초과한다. 그래서 숫자를 받고, 그 값을 카운트해서 그 값을 출력해주면 됨. 입력될 수 있는 수가 10,000,000개라서 이걸 배열이나 벡터에 저장해버리면 당연히 메모리에러가 발생한다. #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int arr[10001]{ 0, }; for (int i = 0; i > a; arr[a]++; } for (int i = 0; i
처음에 이 문제를 봤을때 진짜 queue만 써서 구하는 문제는 아니겠지...?라는 마음으로 접근했는데, queue 자체의 기능을 써도 되는 것 같고, 구조체를 써도 되는 것 같았다. 하지만 구조체를 하직 배우지 않아서 queue를 사용하는 방향으로 문제를 풀었다. #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); int testCase; cin >> testCase; queue q; for (int i = 0; i > s; if (s == "push") { int n; cin >> n; q.push(n); } else if (s == ..
#include using namespace std; int main() { int testCase; cin >> testCase; int apt[15][15]{ 0, }; for (int i = 0; i row >> col; cout
#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c; while (true) { cin >> a >> b >> c; if (a == 0 && b == 0 && c == 0) break; else { if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) { cout