1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     vector<int> numberOfLines(vector<int>& widths, string S) 
12     {
13         int count=1,length=0;
14         for(char c:S)
15         {
16             int cur=widths[c-'a'];
17             if(cur+length<100)
18             {
19                 length+=cur;
20                 continue;
21             }
22             else if(cur+length==100)
23             {
24                 count++;
25                 length=0;
26             }
27             else
28             {
29                 count++;
30                 length=cur;
31             }
32         }
33         return {count,length};
34     }
35 };

直接扫描,统计长度就行,问题不大

posted on 2018-06-14 11:12  高数考了59  阅读(108)  评论(0)    收藏  举报