Submission #26269721


Source Code Expand

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define fi first
#define se second
#define rez resize
#define pb push_back
#define mkp make_pair
#define eb emplace_back
#define debug(...) fprintf (stderr, __VA_ARGS__)

#define Lep(i, l, r) for (int i = l; i < r; ++ i)
#define Rep(i, r, l) for (int i = r; i > l; -- i)
#define lep(i, l, r) for (int i = l; i <= r; ++ i)
#define rep(i, r, l) for (int i = r; i >= l; -- i)

char _c; bool _f; template <class T> inline void IN (T & x) {
	x = 0, _f = 0; while (_c = getchar (), ! isdigit (_c)) if (_c == '-') _f = 1;
	while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
}

template <class T> inline void chkmin (T & x, T y) { if (x > y) x = y; }
template <class T> inline void chkmax (T & x, T y) { if (x < y) x = y; }

const int N = 1e5 + 5;

int n, q, top;
ll a[N], sta[N], cnt[N], tag[N];

void solve (ll len, const ll &val) {
	if (len <= a[0]) return tag[1] += val, tag[len + 1] -= val, void ();
	int pos = upper_bound (a, a + 1 + q, len) - a - 1;
	cnt[pos] += len / a[pos] * val, solve (len % a[pos], val);
}

int main () {
	IN (n), IN (q), sta[top = 0] = 0, a[0] = n;

	lep (i, 1, q) {
		IN (a[i]);
		while (~ top && a[sta[top]] >= a[i]) -- top;
		sta[ ++ top] = i;
	}
	q = top;
	lep (i, 0, q) a[i] = a[sta[i]];

	cnt[q] = 1;
	rep (i, q, 1) cnt[i - 1] += a[i] / a[i - 1] * cnt[i], solve (a[i] % a[i - 1], cnt[i]);
	tag[1] += cnt[0], tag[a[0] + 1] -= cnt[0];
	lep (i, 1, n) tag[i] += tag[i - 1], printf ("%lld\n", tag[i]);
	return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User Qiuly
Language C++ (GCC 9.2.1)
Score 1400
Code Size 1642 Byte
Status AC
Exec Time 57 ms
Memory 6872 KiB

Compile Error

./Main.cpp: In function ‘void IN(T&)’:
./Main.cpp:23:2: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
   23 |  while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
      |  ^~~~~
./Main.cpp:23:63: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
   23 |  while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
      |                                                               ^~

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 34 ms 5304 KiB
02.txt AC 35 ms 5076 KiB
03.txt AC 30 ms 4948 KiB
04.txt AC 29 ms 5320 KiB
05.txt AC 29 ms 5144 KiB
06.txt AC 36 ms 6724 KiB
07.txt AC 40 ms 6664 KiB
08.txt AC 37 ms 6696 KiB
09.txt AC 41 ms 6804 KiB
10.txt AC 35 ms 6764 KiB
11.txt AC 36 ms 6648 KiB
12.txt AC 39 ms 6872 KiB
13.txt AC 38 ms 6660 KiB
14.txt AC 33 ms 6724 KiB
15.txt AC 34 ms 6712 KiB
16.txt AC 36 ms 6764 KiB
17.txt AC 40 ms 6504 KiB
18.txt AC 34 ms 6700 KiB
19.txt AC 36 ms 6712 KiB
20.txt AC 36 ms 6504 KiB
21.txt AC 57 ms 6612 KiB
22.txt AC 35 ms 6660 KiB
23.txt AC 45 ms 6804 KiB
24.txt AC 31 ms 6712 KiB
25.txt AC 27 ms 6660 KiB
26.txt AC 29 ms 6676 KiB
27.txt AC 17 ms 5244 KiB
28.txt AC 24 ms 5080 KiB
29.txt AC 19 ms 5144 KiB
30.txt AC 18 ms 5108 KiB
31.txt AC 3 ms 3652 KiB
32.txt AC 15 ms 4276 KiB
33.txt AC 5 ms 3392 KiB
34.txt AC 28 ms 4388 KiB
35.txt AC 7 ms 3452 KiB
36.txt AC 2 ms 3752 KiB
s1.txt AC 2 ms 3764 KiB
s2.txt AC 3 ms 3748 KiB