Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 백준
- DFS
- 스택
- 다익스트라
- 그래프
- 우선순위 큐
- ue5
- c++
- Unreal Engine 5
- Team Fortress 2
- 시뮬레이션
- 알고리즘
- 구현
- XR Interaction Toolkit
- 다이나믹 프로그래밍
- 트리
- 유니티
- 그리디 알고리즘
- VR
- 백트래킹
- 자료구조
- 수학
- 누적 합
- 유니온 파인드
- BFS
- 투 포인터
- 문자열
- 브루트포스
- 재귀
- 정렬
Archives
- Today
- Total
1일1알
백준 1817번 짐 챙기는 숌 C++ 본문
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
int cnt = 0;
int weight = m;
for (int i = 0; i < n; i++) {
int book;
cin >> book;
if (weight + book > m) {
cnt++;
weight = book;
}
else {
weight += book;
}
}
cout << cnt;
};
'알고리즘' 카테고리의 다른 글
백준 14890번 경사로 C++ (0) | 2022.05.09 |
---|---|
백준 14499번 주사위 굴리기 C++ (0) | 2022.05.08 |
백준 2116번 주사위 쌓기 C++ (0) | 2022.05.05 |
백준 1756번 피자 굽기 C++ (0) | 2022.05.03 |
백준 1544번 사이클 단어 C++ (0) | 2022.05.02 |