C. Permutation Partitions

Link http://codeforces.com/contest/1326/problem/C

Subject to the effect

To give you an array and then you let him into blocks, concrete is divided into k blocks, and then let each piece maximum number and maximum.

practice

Then directly on the array is sorted, take the first k elements of the block and is the largest and the question is how Partitioned program number.

Here just a few of the original columns lined up. Then a maintenance check. Before each encounter is not taking the time to calculate the sum of the elements on ++. Then once encountered a block of the largest element ride took him to the answer inside. That may grouping within this range. In so doing all that is possible in the range. For more details, please see the code, if still do not know Please comment, Insider.

Code

#include<bits/stdc++.h>
using namespace std;
long long a[200005];
long long b[200005];
int mp[200005];
long long mod=998244353;
 
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
        long  long years = 0 ;
    sort(a+1,a+n+1,greater<long long>());
    for(int i=1;i<=k;i++){
            years + = a [i];
        mp [a [i]] = - 1 ;
    }
 
    Long  Long Check = . 1 ;
     Long  Long FA = . 1 ;
    cout<<ans<<" ";
    int flag=0;
    for(int i=1;i<=n;i++){
        if(mp[b[i]]==-1)flag=1;
        if(flag){
        if(mp[b[i]]!=-1)check++;
        else{
            FA * =% check against;
            four = four% mod;
            check=1;
        }
        }
    }
    cout<<fa%mod<<endl;
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/LH2000/p/12528898.html
Recommended