Submission #848252


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;
	vector<ll> _len(Q);
	for (ll& x: _len) scanf("%lld", &x);
	reverse(_len.begin(), _len.end());
	_len.push_back(N);
	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());
	priority_queue<ll_ll> pq;
	pq.push(ll_ll(len[0], 1));
	for (int k = 1; k < Q; k++) {
		ll x = len[k], unko = 0;
		for (;;) {
			ll_ll z = pq.top();
			ll l = z.first;
			if (l < x) break;
			 pq.pop();
			if (l % x) pq.push(ll_ll(l % x, z.second));
			unko += l / x * z.second;
		}
		pq.push(ll_ll(x, unko));
	}
	vector<ll> ans(N + 1);
	while (!pq.empty()) {
		ll_ll z = pq.top(); pq.pop();
		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 1587 Byte
Status TLE
Exec Time 2102 ms
Memory 5868 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37: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 × 35
TLE × 3
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 60 ms 3056 KB
02.txt AC 60 ms 3184 KB
03.txt AC 60 ms 3184 KB
04.txt AC 65 ms 3184 KB
05.txt AC 60 ms 3184 KB
06.txt AC 159 ms 5740 KB
07.txt AC 181 ms 5868 KB
08.txt AC 175 ms 5868 KB
09.txt AC 188 ms 5740 KB
10.txt AC 158 ms 5740 KB
11.txt AC 149 ms 5868 KB
12.txt AC 181 ms 5740 KB
13.txt AC 187 ms 5868 KB
14.txt AC 156 ms 5740 KB
15.txt AC 151 ms 5740 KB
16.txt AC 171 ms 5740 KB
17.txt AC 171 ms 5868 KB
18.txt AC 159 ms 5740 KB
19.txt AC 142 ms 5740 KB
20.txt AC 170 ms 5868 KB
21.txt TLE 2102 ms 4848 KB
22.txt AC 146 ms 5484 KB
23.txt TLE 2101 ms 4848 KB
24.txt AC 100 ms 5740 KB
25.txt AC 99 ms 5612 KB
26.txt AC 90 ms 4848 KB
27.txt AC 38 ms 2032 KB
28.txt AC 38 ms 2032 KB
29.txt AC 38 ms 2032 KB
30.txt AC 39 ms 2032 KB
31.txt AC 4 ms 256 KB
32.txt AC 19 ms 1152 KB
33.txt AC 4 ms 256 KB
34.txt TLE 2101 ms 256 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