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

Ended

Participants:89

Verdict:Accepted
Score:100 / 100
Submitted:2019-03-31 13:03:12

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>
using namespace std;
typedef long long i64;
int n, k;
int a[100010];
i64 S = 0;
bool check(i64 t)
{
    int tk = 0;
    i64 s = 0, _s = 0;
    for (int i = 1; i <= n; i++)
    {
        if (s < t)
            s += a[i];
        if (s>=t)
        {
            tk++;
            s = 0;
            if (tk == k - 1)
            {
                for (int j = i+1; j <= n; j++)
                {
                    _s += a[j];
                }
                break;
            }
        }
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX