Submission #1777227


Source Code Expand

#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int main() {
        int first;
        long long n;
        scanf("%d%lld", &first, &n);
        vector<long long> q(n + 1);
        q[0] = first;
        for (int i = 1; i <= n; i ++) scanf("%lld", &q[i]);
        map<long long, long long, greater<long long>> mp;
        mp[q[n]] = 1;
        for (int i = n - 1; i >= 0; i --) {
                vector<pair<long long, long long>> v;
                for (auto p : mp) {
                        if (p.first <= q[i]) break;
                        v.push_back(make_pair(q[i], (p.first / q[i]) * p.second));
                        v.push_back(make_pair(p.first % q[i], p.second));
                }
                while (mp.size() && q[i] < mp.begin() -> first) mp.erase(mp.begin());
                for (auto p : v) mp[p.first] += p.second;
        }
        vector<long long> sum(first);
        for (auto p : mp) sum[p.first - 1] += p.second;
        for (int i = first - 2; i >= 0; i --) sum[i] += sum[i + 1];
        for (int i = 0; i < first; i ++) printf("%lld\n", sum[i]);
        return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User KokiYmgch
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1157 Byte
Status RE
Exec Time 287 ms
Memory 14064 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:9:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%lld", &first, &n);
                                    ^
./Main.cpp:12:59: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         for (int i = 1; i <= n; i ++) scanf("%lld", &q[i]);
                                                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 25
RE × 13
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 29 ms 3072 KB
02.txt AC 29 ms 3200 KB
03.txt AC 29 ms 3200 KB
04.txt AC 29 ms 3200 KB
05.txt AC 29 ms 3200 KB
06.txt AC 129 ms 12908 KB
07.txt RE 244 ms 13760 KB
08.txt RE 234 ms 13056 KB
09.txt AC 142 ms 10088 KB
10.txt RE 223 ms 10292 KB
11.txt AC 119 ms 11188 KB
12.txt AC 142 ms 13108 KB
13.txt AC 143 ms 14064 KB
14.txt AC 124 ms 11124 KB
15.txt RE 212 ms 11232 KB
16.txt RE 232 ms 13136 KB
17.txt RE 253 ms 13584 KB
18.txt RE 222 ms 12284 KB
19.txt RE 211 ms 12004 KB
20.txt RE 231 ms 13520 KB
21.txt RE 287 ms 7536 KB
22.txt RE 280 ms 11504 KB
23.txt RE 229 ms 7296 KB
24.txt AC 42 ms 3072 KB
25.txt AC 40 ms 2944 KB
26.txt AC 36 ms 2048 KB
27.txt AC 19 ms 2048 KB
28.txt AC 19 ms 2048 KB
29.txt AC 19 ms 2048 KB
30.txt AC 20 ms 2048 KB
31.txt AC 1 ms 256 KB
32.txt AC 10 ms 1152 KB
33.txt AC 1 ms 256 KB
34.txt AC 13 ms 2432 KB
35.txt AC 1 ms 256 KB
36.txt RE 99 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB