From 0d963e43c294cfb308e485ca89177ba8d385f9e5 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Fri, 16 Oct 2020 21:23:45 +0800 Subject: [PATCH] =?UTF-8?q?P1181=20=E6=95=B0=E5=88=97=E5=88=86=E6=AE=B5=20?= =?UTF-8?q?Section=20I?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R39919674 --- problem/P1181/P1181.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 problem/P1181/P1181.cpp 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; +}