Submission #846947


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int m;
int n;
ll q[M];
ll a[M];

void read() {
  cin >> n;
  q[0] = n;
  m = 1;
  
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ll x;
    cin >> x;
    while (m > 0 && q[m - 1] >= x)
      --m;
    q[m++] = x;
  }
}


void kill() {
  map<ll, ll> cnt;

  cnt[q[m - 1]] = 1;

  for (int i = m - 2; i >= 0; --i) {
    ll x = q[i];

    while (true) {
      ll y = cnt.rbegin()->first;
      ll by = cnt.rbegin()->second;

      if (y <= x)
        break;

      cnt.erase(cnt.find(y));

      cnt[x] += (y / x) * by;
      cnt[y % x] += by;
    }
  }

  for (int i = 0; i <= n; ++i)
    a[i] = cnt[i];
  for (int i = n - 1; i >= 1; --i)
    a[i] += a[i + 1];
  for (int i = 1; i <= n; ++i)
    cout << a[i] << "\n";
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User Arterm
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 1024 Byte
Status AC
Exec Time 325 ms
Memory 9600 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 100 ms 8576 KB
02.txt AC 100 ms 8704 KB
03.txt AC 102 ms 8704 KB
04.txt AC 99 ms 8704 KB
05.txt AC 102 ms 8704 KB
06.txt AC 213 ms 9472 KB
07.txt AC 247 ms 9600 KB
08.txt AC 234 ms 9600 KB
09.txt AC 233 ms 9472 KB
10.txt AC 212 ms 9472 KB
11.txt AC 201 ms 9600 KB
12.txt AC 236 ms 9472 KB
13.txt AC 238 ms 9600 KB
14.txt AC 210 ms 9472 KB
15.txt AC 205 ms 9472 KB
16.txt AC 224 ms 9472 KB
17.txt AC 226 ms 9600 KB
18.txt AC 215 ms 9472 KB
19.txt AC 194 ms 9472 KB
20.txt AC 224 ms 9600 KB
21.txt AC 325 ms 8320 KB
22.txt AC 320 ms 9216 KB
23.txt AC 265 ms 9472 KB
24.txt AC 99 ms 9344 KB
25.txt AC 99 ms 9216 KB
26.txt AC 96 ms 8320 KB
27.txt AC 76 ms 7552 KB
28.txt AC 81 ms 7552 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 78 ms 7424 KB
33.txt AC 4 ms 256 KB
34.txt AC 76 ms 8704 KB
35.txt AC 5 ms 256 KB
36.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB