Submission #848245


Source Code Expand

Copy
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

long long q[100005];
int ql[100005];
int ptr;
int res[100005];
map<long long, long long> cnt;

int main(){
    int N, Q;
    scanf("%d%d", &N, &Q);
    ql[ptr++] = 0;
    q[0] = N;
    for(int i=1; i<=Q; i++){
        scanf("%lld", &q[i]);
        while(ptr > 0 && q[ql[ptr-1]] >= q[i]) ql[ptr-1] = 0, ptr--;
        ql[ptr++] = i;
    }
    ptr--;
    cnt[q[Q]] = 1;
    map<long long, long long>::iterator it = cnt.end();
    it--;
    ptr--;
    //printf("%d %d\n", ql[ptr], ptr);
    while(ptr >= 0){
        long long base = q[ql[ptr]];
        while(it->first > q[ql[ptr]]){
            cnt[base] += (it->second) * ((it->first)/base);
            cnt[(it->first)%base] += it->second;
            it->second = 0;
            it--;
        }
        ptr--;
    }
    for(auto ite : cnt){
        //printf("!%lld %lld\n", ite.first, ite.second);
        if(ite.first > N) break;
        res[ite.first] = ite.second;
    }
    for(int i=N; i>=1; i--){
        res[i] += res[i+1];
    }
    for(int i=1; i<=N; i++) printf("%d\n", res[i]);
    return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User zoomswk
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1179 Byte
Status WA
Exec Time 549 ms
Memory 24576 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &Q);
                          ^
./Main.cpp:18:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &q[i]);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 10
WA × 28
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 WA 57 ms 2432 KB
02.txt WA 58 ms 2432 KB
03.txt WA 58 ms 2432 KB
04.txt WA 59 ms 2432 KB
05.txt WA 59 ms 2432 KB
06.txt WA 259 ms 20480 KB
07.txt WA 301 ms 24576 KB
08.txt WA 286 ms 22016 KB
09.txt WA 303 ms 23552 KB
10.txt WA 260 ms 20096 KB
11.txt WA 231 ms 18560 KB
12.txt WA 279 ms 23424 KB
13.txt WA 282 ms 23936 KB
14.txt WA 249 ms 20096 KB
15.txt WA 240 ms 18944 KB
16.txt WA 269 ms 21632 KB
17.txt WA 285 ms 22272 KB
18.txt WA 265 ms 20992 KB
19.txt WA 234 ms 17664 KB
20.txt WA 270 ms 21760 KB
21.txt WA 549 ms 23936 KB
22.txt WA 500 ms 24064 KB
23.txt WA 328 ms 15232 KB
24.txt WA 95 ms 8704 KB
25.txt WA 100 ms 9088 KB
26.txt WA 91 ms 8192 KB
27.txt AC 36 ms 1536 KB
28.txt AC 36 ms 1536 KB
29.txt AC 36 ms 1536 KB
30.txt AC 37 ms 1536 KB
31.txt AC 4 ms 256 KB
32.txt AC 18 ms 768 KB
33.txt AC 4 ms 256 KB
34.txt WA 24 ms 1664 KB
35.txt AC 7 ms 256 KB
36.txt WA 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB