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

Ended

Participants:899

Verdict:Time Limit Exceeded
Score:40 / 100
Submitted:2016-08-07 14:10:39

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 <cstdio>
#include <cstring>
using namespace std;
int a[110];
char s[1010];
int main()
{
    //freopen("in.txt","r",stdin);
    int n,m,k;
    int x,y;
    x=y=1;
    scanf("%d%d",&n,&m);
    k=0;
    while(scanf("%s",s)!=EOF)
    {
        a[k]=strlen(s);
        k++;
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<k;j++)
        {
            if(ans+a[j]<=m)
            {
                if(ans+a[j]+1<=m)
                    ans+=a[j]+1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX