Contest Duration: - (local time) (110 minutes) Back to Home

Submission #848311

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 2016-08-21 22:47:34+0900 E - Sequential operations on Sequence sugim48 C++14 (GCC 5.4.1) 0 1588 Byte TLE 2105 ms 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 × 37 TLE × 1
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 61 ms 3056 KB
02.txt AC 61 ms 3184 KB
03.txt AC 62 ms 3184 KB
04.txt AC 61 ms 3184 KB
05.txt AC 63 ms 3184 KB
06.txt AC 161 ms 5740 KB
07.txt AC 181 ms 5868 KB
08.txt AC 173 ms 5868 KB
09.txt AC 185 ms 5740 KB
10.txt AC 160 ms 5740 KB
11.txt AC 149 ms 5868 KB
12.txt AC 185 ms 5740 KB
13.txt AC 187 ms 5868 KB
14.txt AC 157 ms 5740 KB
15.txt AC 152 ms 5740 KB
16.txt AC 169 ms 5740 KB
17.txt AC 170 ms 5868 KB
18.txt AC 159 ms 5740 KB
19.txt AC 143 ms 5740 KB
20.txt AC 174 ms 5868 KB
21.txt AC 255 ms 4848 KB
22.txt AC 147 ms 5484 KB
23.txt AC 189 ms 5740 KB
24.txt AC 104 ms 5740 KB
25.txt AC 100 ms 5612 KB
26.txt AC 92 ms 4848 KB
27.txt AC 39 ms 2032 KB
28.txt AC 39 ms 2032 KB
29.txt AC 38 ms 2032 KB
30.txt AC 40 ms 2032 KB
31.txt AC 4 ms 256 KB
32.txt AC 20 ms 1152 KB
33.txt AC 4 ms 256 KB
34.txt TLE 2105 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