Submission #1777241


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 + 1);
        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 1159 Byte
Status RE
Exec Time 280 ms
Memory 13876 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 126 ms 12012 KB
07.txt RE 238 ms 13112 KB
08.txt RE 230 ms 13056 KB
09.txt AC 139 ms 9832 KB
10.txt RE 220 ms 10932 KB
11.txt AC 117 ms 11060 KB
12.txt AC 143 ms 13876 KB
13.txt AC 143 ms 13424 KB
14.txt AC 124 ms 11764 KB
15.txt RE 211 ms 11232 KB
16.txt RE 227 ms 13648 KB
17.txt RE 226 ms 12304 KB
18.txt RE 222 ms 12284 KB
19.txt RE 206 ms 11492 KB
20.txt RE 225 ms 13776 KB
21.txt RE 280 ms 7536 KB
22.txt RE 278 ms 12400 KB
23.txt RE 224 ms 7296 KB
24.txt AC 40 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 19 ms 2048 KB
31.txt AC 1 ms 256 KB
32.txt AC 9 ms 1152 KB
33.txt AC 1 ms 256 KB
34.txt AC 12 ms 2432 KB
35.txt AC 1 ms 256 KB
36.txt RE 96 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB