문제 링크: https://www.acmicpc.net/problem/18322
18322번: Word Processor
Including "hello" and "my", the first line contains 7 non-space characters. Adding "name" would cause the first line to contain $11>7$ non-space characters, so it is placed on a new line.
www.acmicpc.net
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
|
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s[101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i = 0; i < n; i++) cin >> s[i];
int len = 0;
for(int i = 0; i < n; i++) {
len += s[i].size();
if(len <= k) {
cout << s[i] << ' ';
}
else {
cout << '\n' << s[i] << ' ';
len = s[i].size();
}
}
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 18786 Triangles (USACO February 2020 Bronze 1번) (0) | 2020.03.22 |
---|---|
백준 18323 Photoshoot (USACO January 2020 Bronze 2번) (0) | 2020.03.21 |
백준 18270 Livestock Lineup (USACO December 2019 Bronze 3번) (0) | 2020.03.20 |
백준 18269 Where Am I? (USACO December 2019 Bronze 2번) (0) | 2020.03.20 |
백준 18268 Cow Gymnastics (USACO December 2019 Bronze 1번) (0) | 2020.03.18 |