Submission #19724635


Source Code Expand

Copy
#include <bits/stdc++.h>
#define INF 999999
using namespace std;
typedef long long ll;
ll N, M;


int main(){
    ll ans=0;
    cin >> N >> M;
    if(M==0){
        cout << 1 << endl;
        return 0;
    }
    
    ll A[M+2];
    A[0] = 0;
    A[M+1] = N+1;
    for(int i=1; i<=M; i++){
        cin >> A[i];
    }
    if(N<M){
        cout << 0 << endl;
        return 0;
    }
    sort(A, A+M+2);

    ll shironum = 0;
    ll cnt=0;
    ll K = N;
    map<ll,ll> mp;
    for(int i=1; i<M+2; i++){
        if(A[i]-A[i-1]-1 >0){
            K = min(K, A[i]-A[i-1]-1 );
            // cout<<A[i]-A[i-1]<<endl;
            mp[A[i]-A[i-1]-1]++;
        }
    }
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        // cout << "key = " << iter->first << "\n";
        // cout << "value = " << iter->second << "\n";
        ans += ((iter->first + (K-1)) / K) *iter->second;
    }

    cout << ans << endl;
    
    return 0;
}



Submission Info

Submission Time
Task D - Stamp
User k0m
Language C++ (GCC 9.2.1)
Score 400
Code Size 1029 Byte
Status AC
Exec Time 107 ms
Memory 6444 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:8: warning: unused variable ‘shironum’ [-Wunused-variable]
   29 |     ll shironum = 0;
      |        ^~~~~~~~
./Main.cpp:30:8: warning: unused variable ‘cnt’ [-Wunused-variable]
   30 |     ll cnt=0;
      |        ^~~

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 3516 KB
handmade_01.txt AC 2 ms 3444 KB
random_00.txt AC 2 ms 3364 KB
random_01.txt AC 2 ms 3372 KB
random_02.txt AC 74 ms 6144 KB
random_03.txt AC 105 ms 6444 KB
random_04.txt AC 3 ms 3440 KB
random_05.txt AC 71 ms 6152 KB
random_06.txt AC 107 ms 6332 KB
random_07.txt AC 2 ms 3500 KB
random_08.txt AC 2 ms 3552 KB
random_09.txt AC 71 ms 5012 KB
random_10.txt AC 2 ms 3372 KB
random_11.txt AC 49 ms 4384 KB
random_12.txt AC 2 ms 3500 KB
random_13.txt AC 3 ms 3532 KB
random_14.txt AC 82 ms 4856 KB
random_15.txt AC 54 ms 4732 KB
random_16.txt AC 2 ms 3508 KB
random_17.txt AC 4 ms 3408 KB
random_18.txt AC 88 ms 5292 KB
random_19.txt AC 3 ms 3444 KB
random_20.txt AC 2 ms 3508 KB
random_21.txt AC 12 ms 3676 KB
random_22.txt AC 2 ms 3456 KB
random_23.txt AC 7 ms 3584 KB
sample_01.txt AC 3 ms 3428 KB
sample_02.txt AC 2 ms 3372 KB
sample_03.txt AC 2 ms 3372 KB
sample_04.txt AC 3 ms 3432 KB