[Offer收割]编程练习赛4 register

Ended

Participants:899

Verdict:Wrong Answer
Score:40 / 100
Submitted:2016-08-07 12:58:34

Lang:Java

Edit
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
29
30
31
import java.util.Scanner;
/**
 * Created by jwli on 16/8/2.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        in.nextLine();
        String input = in.nextLine();
        String[] words = input.split(" ");
        int[] lens = new int[words.length];
        for (int i = 0i < lens.lengthi++) {
            lens[i= words[i].length();
        }
        int r = 1;
        int c = 0;
        for (int i = 1i <= ni++) {
            for (int j = 0j < lens.length;) {
                if ((m - c>= lens[j]) {
                    c = c + lens[j];
                    j++;
                } else {
                    c = m - 1;
                }
                if (c == m) {
                    r += 1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX