結果

問題 No.2561 みんな大好きmod 998
ユーザー NATTONATTO
提出日時 2023-12-02 14:57:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 336 ms / 4,000 ms
コード長 2,882 bytes
コンパイル時間 5,218 ms
コンパイル使用メモリ 310,620 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 14:57:54
合計ジャッジ時間 10,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 19 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 322 ms
6,548 KB
testcase_04 AC 319 ms
6,548 KB
testcase_05 AC 318 ms
6,548 KB
testcase_06 AC 336 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 1 ms
6,548 KB
testcase_11 AC 48 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 320 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 235 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 86 ms
6,548 KB
testcase_27 AC 321 ms
6,548 KB
testcase_28 AC 84 ms
6,548 KB
testcase_29 AC 27 ms
6,548 KB
testcase_30 AC 85 ms
6,548 KB
testcase_31 AC 170 ms
6,548 KB
testcase_32 AC 34 ms
6,548 KB
testcase_33 AC 27 ms
6,548 KB
testcase_34 AC 321 ms
6,548 KB
testcase_35 AC 21 ms
6,548 KB
testcase_36 AC 21 ms
6,548 KB
testcase_37 AC 11 ms
6,548 KB
testcase_38 AC 49 ms
6,548 KB
testcase_39 AC 85 ms
6,548 KB
testcase_40 AC 85 ms
6,548 KB
testcase_41 AC 49 ms
6,548 KB
testcase_42 AC 85 ms
6,548 KB
testcase_43 AC 11 ms
6,548 KB
testcase_44 AC 36 ms
6,548 KB
testcase_45 AC 236 ms
6,548 KB
testcase_46 AC 27 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region header
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

// clang-format off

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

inline void IN(void)
{
    return;
}

template <typename First, typename... Rest>
void IN(First &first, Rest &...rest)
{
    cin >> first;
    IN(rest...);
    return;
}
template <typename T>
istream &operator>>(istream &is, pair<T, T> &p)
{
    is >> p.first >> p.second;
    return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &x : v)
        is >> x;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    for (auto &x : v)
        os << x << " ";
    os << endl;
    return os;
}

// templetes
//alias
 
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
using pll = pair<ll, ll>;
 
//define short
#define vec vector
#define all(obs) (obs).begin(), (obs).end()
#define YESNO(cond) (cond) ? cout << "YES" << endl : cout << "NO" << endl;
#define YesNo(cond) (cond) ? cout << "Yes" << endl : cout << "No" << endl;
#define yesno(cond) (cond) ? cout << "yes" << endl : cout << "no" << endl;
#define sortv(obs) sort(all(obs))
#define rsortv(obs) reverse(sort(all(obs)))
#define bitu(n,i) (((n)>>(i))&1)
#define dig10(n) to_string(n).size()
#define bcnt(n) __builtin_popcount(n)
#define bcntll(n) __builtin_popcountll(n)
#define F first
#define S second
#define pb push_back
#define pq priority_queue


//define loop
#define rep(i, a,b) for(ll i = a; i < (b); i++)
#define rrep(i, a,b) for(ll i = a; i >= (b); i--)
//define INF
const ll INF = 1e18;

template <typename T1,typename T2>
inline void chmin(T1 &a,T2 b){
    if(a>b) a = b;
}
template <typename T1,typename T2>
inline void chmax(T1 &a,T2 b){
    if(a<b) a = b;
}


#pragma endregion header

// clang-format on

ll inv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t*b; swap(a,b);
        u -= t*v; swap(u,v);
    }
    u %= m;
    if(u<0) u += m;
    return u;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vll a(n);
    cin >> a;
    ll ans=0;
    auto dfs=[&](auto dfs, ll i,vll v){
        if(i>=n-1&&v.size()<k){
            return;
        }
        if(v.size()==k){
            ll s1=0,s2=0;
            rep(j,0,k){
                s1+=a[v[j]]%998;
                s1%=998;
                s2+=a[v[j]]%998244353;
                s2%=998244353;
            }
            if(s1>=s2) ans++;
            ans%=998;
            return;
        }
        rep(j,i+1,n){
            v.pb(j);
            dfs(dfs,j,v);
            v.pop_back();
        }
    };
    dfs(dfs,-1,{});
    cout << ans << endl;
}
0