Submission #847755


Source Code Expand

Copy
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, Q; cin >> N >> Q;
	if (!Q) {
		while (N--) cout << 1 << endl;
		return 0;
	}
	vector<ll> _len(Q);
	for (ll& x: _len) scanf("%lld", &x);
	reverse(_len.begin(), _len.end());
	vector<ll> len;
	ll mi = LLONG_MAX;
	for (ll x: _len)
		if (x < mi) {
			len.push_back(x);
			mi = x;
		}
	Q = len.size();
	// reverse(len.begin(), len.end());
	map<ll, ll> mp;
	mp[len[0]] = 1;
	for (int k = 1; k < Q; k++) {
		ll x = len[k];
		for (;;) {
			auto it = mp.end(); it--;
			ll l = it->first;
			if (l <= x) break;
			if (l % x) mp[l % x]++;
			mp[x] += l / x;
			it->second--;
			if (!it->second) mp.erase(it);
		}
	}
	vector<ll> ans(N + 1);
	for (ll_ll z: mp) ans[z.first] += z.second;
	for (int i = N - 1; i >= 0; i--)
		ans[i] += ans[i + 1];
	for (int i = 1; i <= N; i++)
		printf("%lld\n", ans[i]);
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User sugim48
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1543 Byte
Status WA
Exec Time 2105 ms
Memory 8052 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (ll& x: _len) scanf("%lld", &x);
                                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 8
WA × 1
TLE × 6
RE × 23
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 RE 227 ms 1792 KB
02.txt RE 237 ms 1792 KB
03.txt RE 229 ms 1792 KB
04.txt RE 229 ms 1792 KB
05.txt RE 235 ms 1792 KB
06.txt RE 330 ms 7412 KB
07.txt RE 372 ms 7412 KB
08.txt RE 367 ms 7412 KB
09.txt RE 486 ms 7412 KB
10.txt RE 331 ms 7412 KB
11.txt RE 312 ms 7412 KB
12.txt RE 399 ms 7412 KB
13.txt RE 495 ms 7412 KB
14.txt RE 325 ms 7412 KB
15.txt RE 324 ms 7412 KB
16.txt RE 354 ms 7412 KB
17.txt RE 349 ms 7412 KB
18.txt RE 326 ms 7412 KB
19.txt RE 302 ms 7412 KB
20.txt RE 358 ms 7412 KB
21.txt TLE 2105 ms 7924 KB
22.txt TLE 2105 ms 7924 KB
23.txt TLE 2105 ms 8052 KB
24.txt TLE 2105 ms 2168 KB
25.txt TLE 2105 ms 2168 KB
26.txt TLE 2105 ms 2168 KB
27.txt AC 37 ms 2048 KB
28.txt AC 38 ms 2048 KB
29.txt AC 38 ms 2048 KB
30.txt WA 38 ms 2048 KB
31.txt AC 4 ms 256 KB
32.txt AC 650 ms 384 KB
33.txt AC 4 ms 256 KB
34.txt RE 194 ms 1024 KB
35.txt RE 192 ms 256 KB
36.txt RE 205 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB