From f48043121567310713967805b927f371d15cdb51 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Fri, 31 Jul 2026 13:07:48 +0900 Subject: [PATCH] =?UTF-8?q?1911=20:=20=ED=9D=99=EA=B8=B8=20=EB=B3=B4?= =?UTF-8?q?=EC=88=98=ED=95=98=EA=B8=B0=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week5/BOJ1911/BOJ1911_V1.cpp | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/week5/BOJ1911/BOJ1911_V1.cpp diff --git a/src/week5/BOJ1911/BOJ1911_V1.cpp b/src/week5/BOJ1911/BOJ1911_V1.cpp new file mode 100644 index 0000000..8881a62 --- /dev/null +++ b/src/week5/BOJ1911/BOJ1911_V1.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; +vector> inp; +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + int N,L; + cin >> N >> L; + + for (int i=0; i> st >> ed; + inp.push_back({st,ed}); + } + + sort(inp.begin(), inp.end()); + + int ret = 0; + int st =0, ed=0; + for (pair curr : inp) { + int cnt = 0; + if (ed >= curr.second) continue; + + if (ed < curr.first) { + st = curr.first; + } else { + st = ed; + } + ed = curr.second; + + cnt += (ed-st)/L; + if ((ed-st)%L) cnt+=1; + ret += cnt; + ed = st + L * cnt; + } + cout << ret; + + return 0; +} \ No newline at end of file