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

Ended

Participants:899

Verdict:Wrong Answer
Score:50 / 100
Submitted:2016-08-07 14:27:34

Lang:G++

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
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> nums;
    string s;
    while(cin >> s) {
        nums.push_back(1);
        nums.push_back(s.size());
    }
    unordered_map<int, int> ydict, xdict;
    int x = 0, y = 0;
    for (int i = 1; i < nums.size(); ++i) {
        int num = nums[i];
        if (y == 0)
            ++x;
        if (y + num <= m)
            y += num;
        else {
            y = num;
            ++x;
        }
        if (y >= m)
            y -= m;
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX