Submission #18739592


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define CREP(i, l, r) for(int i = l; i <= r; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    if(m == 0){
        puts("1");
        return 0;
    }

    vi a(m);
    rep(i,m) scanf("%d", &a[i]);
    sort(a.begin(), a.end());

    vi d(m+1);
    rep(i,m){
        if(i == 0) d[i] = a[i]-1;
        else d[i] = a[i]-a[i-1]-1;
        if(i == m-1) d[m] = n-a[i];
    }

    int mn = n;
    rep(i,m+1) if(d[i] != 0 && d[i] < mn) mn = d[i];
    
    int ans = 0;
    rep(i,m+1) {
        if(d[i] != 0) {
            ans += (d[i]+mn-1)/mn;
        }
    }

    printf("%d\n", ans);
}

Submission Info

Submission Time
Task D - Stamp
User samari06
Language C++ (GCC 9.2.1)
Score 400
Code Size 800 Byte
Status AC
Exec Time 47 ms
Memory 4832 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:18:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   18 |     rep(i,m) scanf("%d", &a[i]);
      |              ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
handmade_00.txt AC 8 ms 3684 KiB
handmade_01.txt AC 2 ms 3636 KiB
random_00.txt AC 2 ms 3652 KiB
random_01.txt AC 2 ms 3640 KiB
random_02.txt AC 34 ms 4304 KiB
random_03.txt AC 43 ms 4740 KiB
random_04.txt AC 2 ms 3652 KiB
random_05.txt AC 33 ms 4252 KiB
random_06.txt AC 42 ms 4596 KiB
random_07.txt AC 2 ms 3732 KiB
random_08.txt AC 1 ms 3532 KiB
random_09.txt AC 37 ms 4832 KiB
random_10.txt AC 3 ms 3604 KiB
random_11.txt AC 36 ms 4208 KiB
random_12.txt AC 2 ms 3580 KiB
random_13.txt AC 2 ms 3720 KiB
random_14.txt AC 42 ms 4564 KiB
random_15.txt AC 33 ms 4440 KiB
random_16.txt AC 2 ms 3672 KiB
random_17.txt AC 2 ms 3708 KiB
random_18.txt AC 47 ms 4604 KiB
random_19.txt AC 2 ms 3660 KiB
random_20.txt AC 2 ms 3612 KiB
random_21.txt AC 11 ms 3924 KiB
random_22.txt AC 2 ms 3620 KiB
random_23.txt AC 7 ms 3704 KiB
sample_01.txt AC 2 ms 3656 KiB
sample_02.txt AC 2 ms 3736 KiB
sample_03.txt AC 2 ms 3780 KiB
sample_04.txt AC 2 ms 3684 KiB