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

Submission #848645

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());
vector<ll> dp(Q), ans(N + 1);
dp[Q - 1] = 1;
for (int k = Q - 1; k >= 0; k--) {
ll x = len[k], z = dp[k];
for (;;) {
int k = lower_bound(len.begin(), len.end(), x) - len.begin();
if (!k) break;
k--;
dp[k] += (x / len[k]) * z;
x %= len[k];
}
ans[x] += z;
}
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 23:20:35+0900 E - Sequential operations on Sequence sugim48 C++14 (GCC 5.4.1) 1400 1438 Byte AC 133 ms 4848 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 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 62 ms 3056 KB
02.txt AC 60 ms 3184 KB
03.txt AC 60 ms 3184 KB
04.txt AC 60 ms 3184 KB
05.txt AC 62 ms 3184 KB
06.txt AC 92 ms 4720 KB
07.txt AC 98 ms 4848 KB
08.txt AC 96 ms 4848 KB
09.txt AC 101 ms 4720 KB
10.txt AC 93 ms 4720 KB
11.txt AC 89 ms 4848 KB
12.txt AC 99 ms 4720 KB
13.txt AC 104 ms 4848 KB
14.txt AC 92 ms 4720 KB
15.txt AC 90 ms 4720 KB
16.txt AC 96 ms 4720 KB
17.txt AC 96 ms 4848 KB
18.txt AC 92 ms 4720 KB
19.txt AC 87 ms 4720 KB
20.txt AC 96 ms 4848 KB
21.txt AC 133 ms 3568 KB
22.txt AC 87 ms 4464 KB
23.txt AC 113 ms 4720 KB
24.txt AC 70 ms 4720 KB
25.txt AC 70 ms 4592 KB
26.txt AC 60 ms 3568 KB
27.txt AC 39 ms 2032 KB
28.txt AC 39 ms 2032 KB
29.txt AC 52 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 AC 28 ms 2432 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