結果

問題 No.1972 Modulo Set
ユーザー mnmmnm
提出日時 2022-06-13 20:34:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,293 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 83,424 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 16:20:05
合計ジャッジ時間 16,273 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 48 ms
6,676 KB
testcase_04 AC 60 ms
6,676 KB
testcase_05 AC 48 ms
6,676 KB
testcase_06 AC 152 ms
6,676 KB
testcase_07 AC 301 ms
6,676 KB
testcase_08 AC 38 ms
6,676 KB
testcase_09 AC 10 ms
6,676 KB
testcase_10 AC 47 ms
6,676 KB
testcase_11 AC 323 ms
6,676 KB
testcase_12 AC 26 ms
6,676 KB
testcase_13 AC 71 ms
6,676 KB
testcase_14 AC 59 ms
6,676 KB
testcase_15 AC 1,023 ms
6,676 KB
testcase_16 AC 1,802 ms
6,676 KB
testcase_17 AC 177 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 1,595 ms
6,676 KB
testcase_20 TLE -
testcase_21 AC 255 ms
6,676 KB
testcase_22 AC 1,379 ms
6,676 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <bitset>

#define rep(i,n) for(i=0; i<n; ++i)
#define in(a) cin >> a
#define out(a,b) cout << a << b
using namespace std;
using lint = long long;

lint count_elem_inc(vector<lint> x, lint elem, lint *i){
    lint cnt=0;
    for(; *i<x.size(); ++*i){
        if(x[*i]!=elem)  break;
        cnt++;
    }
    return cnt;
}
lint count_elem_dec(vector<lint> x, lint elem, lint *i){
    lint cnt=0;
    for(; *i>0; --*i){
        if(x[*i]!=elem)  break;
        cnt++;
    }
    return cnt;
}

int main(void){
    lint i, j;
    lint p, n, m, cnt=0;
    in(n); in(m);
    vector<lint> rem(n);
    rep(i,n){
        lint input;
        in(input);
        rem[i]=input%m;
    }
    sort(rem.begin(),rem.end());
    lint *cur_l, *cur_r;
    lint init_l=0, init_r=n-1;
    cur_l=&init_l; cur_r=&init_r;
    for(i=1; i<m/2+m%2; ++i){
        for(; rem[*cur_l]<i; ++*cur_l);
        for(; rem[*cur_r]>m-i; --*cur_r);
        lint l_cnt=count_elem_inc(rem, i, cur_l);
        lint r_cnt=count_elem_dec(rem, m-i, cur_r);
        cnt+=max(l_cnt,r_cnt);
    }
    if(m%2==0&&rem[*cur_l]==m/2)  cnt++;
    if(rem[0]==0)    cnt++;
    if(cnt==0)  cnt=1;
    out(cnt,endl);

    return 0;
}
0