Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
123187762 Practice:
parveen1981
1342D - 19 C++17 (GCC 9-64) Wrong answer on test 11 31 ms 4996 KB 2021-07-21 15:13:39 2021-07-21 15:13:39
→ Source
#include <bits/stdc++.h> 
using namespace std;
const int N=200009;
const int mod=1e9 + 7;

template <typename A, typename B> string to_string(pair<A, B> p); string to_string(const string& s) {return '"' + s + '"'; } string to_string(const __int128 & x){__int128 y=x; bool minus=false; if(y<0){y=-y; minus=true; } string s=""; while(y>0){char w='0' + y%10; s.push_back(w); y/=10; } if(minus){s.push_back('-'); } reverse(s.begin(),s.end()); if(s.empty()) s="0"; return s; } string to_string(bool b) {return (b ? "true" : "false"); } string to_string(vector<bool> v) {bool first = true; string res = "{"; for (int i = 0; i < static_cast<int>(v.size()); i++) {if (!first) {res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template <typename A> string to_string(A v) {bool first = true; string res = "{"; for (const auto &x : v) {if (!first) {res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template <typename A, typename B> string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } vector<string> vars; int varNumber; void parseVariables(string s){vars.clear(); string temp=""; for(const auto &c:s){if(c==','){vars.push_back(temp); temp=""; } else{temp+=c; } } vars.push_back(temp); varNumber=0; } void debugOut(){ cerr<<endl; } template<typename Head, typename... Tail> void debugOut(Head H,Tail... T){if(varNumber!=0) cerr<<"    "; cerr<<"["<<vars[varNumber++]<<"]:"<<to_string(H); debugOut(T...); }
#ifndef ONLINE_JUDGE
#define gin(...){ parseVariables(#__VA_ARGS__); debugOut(__VA_ARGS__); }
#else
#define gin(...) 42
#endif

void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> m(n),c(k+1);
    for(int i=0;i<n;i++){
        cin>>m[i];
    }
    for(int i=1;i<=k;i++){
        cin>>c[i];
    }
    sort(m.begin(), m.end());
    // gin(m);
    vector<vector<int>> sol;
    int cnt=N;
    vector<int> temp;
    for(int i=0;i<n;i++){
        cnt=min(cnt-1,c[m[i]]-1);
        temp.push_back(m[i]);
        if(cnt==0){
            sol.push_back(temp);
            temp.clear();
            cnt=N;
        }
    }
    if(!temp.empty()){
        sol.push_back(temp);
    }
    cout<<sol.size()<<endl;
    for(const auto &v:sol){
        cout<<v.size()<<" ";
        for(const auto &ele:v){
            cout<<ele<<" ";
        }
        cout<<endl;
    }
}

int32_t main(){
    cin.tie(NULL)->sync_with_stdio(false);
    solve();
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details