Submission #847074


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mq;
map<in,in> qc;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,q;
  cin>>n>>q;
  mq.resize(q+1);
  mq[0]=n;
  forn(i,q)
    cin>>mq[i+1];
  reverse(all(mq));
  in rr=1;
  for(in i=1;i<=q;++i){
    if(mq[i]<mq[rr-1])
      mq[rr++]=mq[i];
  }
  mq.resize(rr);
  reverse(all(mq));
  qc[-mq.back()]=1;
  map<in,in>::iterator it;
  in id;
  while(1){
    it=qc.begin();
    if(-it->first<=mq[0])
      break;
    id=lower_bound(all(mq),-it->first)-mq.begin();
    --id;
    qc[-mq[id]]+=(-it->first)/mq[id]*it->second;
    qc[-((-it->first)%mq[id])]+=it->second;
    qc.erase(it);
  }
  in tt=0;
  fors(i,qc)
    tt+=i->second;
  tt-=qc[0];
  for(in i=1;i<=n;++i){
    cout<<tt<<"\n";
    tt-=qc[-i];
  }
  return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User w4yneb0t
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 1243 Byte
Status AC
Exec Time 301 ms
Memory 8704 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 2
AC × 38
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 103 ms 8576 KB
02.txt AC 104 ms 8704 KB
03.txt AC 101 ms 8704 KB
04.txt AC 101 ms 8704 KB
05.txt AC 103 ms 8704 KB
06.txt AC 222 ms 8704 KB
07.txt AC 255 ms 8704 KB
08.txt AC 237 ms 8704 KB
09.txt AC 244 ms 8704 KB
10.txt AC 224 ms 8704 KB
11.txt AC 210 ms 8704 KB
12.txt AC 247 ms 8704 KB
13.txt AC 248 ms 8704 KB
14.txt AC 217 ms 8704 KB
15.txt AC 212 ms 8704 KB
16.txt AC 232 ms 8704 KB
17.txt AC 235 ms 8704 KB
18.txt AC 225 ms 8704 KB
19.txt AC 202 ms 8704 KB
20.txt AC 232 ms 8704 KB
21.txt AC 301 ms 7552 KB
22.txt AC 292 ms 8448 KB
23.txt AC 231 ms 8704 KB
24.txt AC 113 ms 8576 KB
25.txt AC 116 ms 8448 KB
26.txt AC 105 ms 7552 KB
27.txt AC 76 ms 7552 KB
28.txt AC 80 ms 7424 KB
29.txt AC 80 ms 7552 KB
30.txt AC 83 ms 7552 KB
31.txt AC 4 ms 256 KB
32.txt AC 69 ms 6656 KB
33.txt AC 4 ms 256 KB
34.txt AC 73 ms 7936 KB
35.txt AC 4 ms 256 KB
36.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB