diff --git a/problem/P1181/P1181.cpp b/problem/P1181/P1181.cpp new file mode 100644 index 00000000..0c2e88ae --- /dev/null +++ b/problem/P1181/P1181.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main() { + int n, m, sum = 0, ans = 1, t; + cin >> n >> m; + for (int i = 0; i < n; i++) { + cin >> t; + if (sum + t > m) { + ans++; + sum = t; + } + else { + sum += t; + } + } + cout << ans << endl; + return 0; +}