System Testing(Codeforces Round #543 (Div. 2, based on Technocup 2019 Final Round))D

C. System Testing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.

There are nn solutions, the ii-th of them should be tested on aiai tests, testing one solution on one test takes 11 second. The solutions are judged in the order from 11 to nn. There are kk testing processes which test solutions simultaneously. Each of them can test at most one solution at a time.

At any time moment tt when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id ii, then it is being tested on the first test from time moment tt till time moment t+1t+1, then on the second test till time moment t+2t+2 and so on. This solution is fully tested at time moment t+ait+ai, and after that the testing process immediately starts testing another solution.

Consider some time moment, let there be exactly mm fully tested solutions by this moment. There is a caption "System testing: dd%" on the page with solutions, where dd is calculated as

d=round(100⋅mn),d=round(100⋅mn),

where round(x)=⌊x+0.5⌋round(x)=⌊x+0.5⌋ is a function which maps every real to the nearest integer.

Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test qq, and the caption says "System testing: qq%". Find the number of interesting solutions.

Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter.

Input

The first line contains two positive integers nn and kk (1≤n≤10001≤n≤1000, 1≤k≤1001≤k≤100) standing for the number of submissions and the number of testing processes respectively.

The second line contains nn positive integers a1,a2,…,ana1,a2,…,an (1≤ai≤1501≤ai≤150), where aiai is equal to the number of tests the ii-th submission is to be run on.

Output

Output the only integer — the number of interesting submissions.

Examples

input

Copy

2 2
49 100

output

Copy

1

input

Copy

4 2
32 100 33 1

output

Copy

2

input

Copy

14 5
48 19 6 9 50 20 3 42 38 43 36 21 44 6

output

Copy

5

Note

Consider the first example. At time moment 00 both solutions start testing. At time moment 4949 the first solution is fully tested, so at time moment 49.549.5 the second solution is being tested on the test 5050, and the caption says "System testing: 5050%" (because there is one fully tested solution out of two). So, the second solution is interesting.

Consider the second example. At time moment 00 the first and the second solutions start testing. At time moment 3232 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 2525%". At time moment 32+24.5=56.532+24.5=56.5 the third solutions is being tested on test 2525, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32+33=6532+33=65, the fourth solution is fully tested at time moment 65+1=6665+1=66. The captions becomes "System testing: 7575%", and at time moment 74.574.5 the second solution is being tested on test 7575. So, this solution is also interesting. Overall, there are two interesting solutions.

简单的模拟只有500+人ac 

可能并不是所有人都solve proplem for fun 吧

挂上代码 警醒自己要注意计算中间过程的精度问题

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
queue<int> q;
int test[105];
int process[105];
int vis[105];
int main()
{
    int n,k,temp,fin=0,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&temp);
        q.push(temp);
    }
    memset(test,0,sizeof(test));
    memset(vis,0,sizeof(vis));
    memset(process,0,sizeof(process));
    for(int i=1; i<=k; i++)
    {
        if(q.size()==0) continue;
        temp=q.front();
        q.pop();
        test[i]=temp;
    }
    int sta;
    double temp2;
    while(fin!=n)
    {
        temp2=100.00*fin/n+0.5;
        sta=(int) (temp2);
        for(int i=1; i<=k; i++)
        {
            if(test[i]==0) continue;
            process[i]++;
            if(process[i]==sta&&vis[i]==0)  vis[i]++,ans++;
            if(process[i]==test[i])
            {
                vis[i]=0;
                fin++;
                process[i]=0;
                if(!q.size()) test[i]=0;
                else test[i]=q.front(),q.pop();
            }
        }
    }
    printf("%d\n",ans);
}

猜你喜欢

转载自blog.csdn.net/caowenbo2311694605/article/details/88168960