結果

問題 No.2561 みんな大好きmod 998
ユーザー strawberry0929strawberry0929
提出日時 2023-12-02 14:59:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 4,000 ms
コード長 1,761 bytes
コンパイル時間 3,332 ms
コンパイル使用メモリ 230,688 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 14:59:15
合計ジャッジ時間 5,679 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 6 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 106 ms
6,548 KB
testcase_04 AC 105 ms
6,548 KB
testcase_05 AC 108 ms
6,548 KB
testcase_06 AC 103 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 2 ms
6,548 KB
testcase_11 AC 16 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 106 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 76 ms
6,548 KB
testcase_20 AC 1 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 1 ms
6,548 KB
testcase_24 AC 1 ms
6,548 KB
testcase_25 AC 1 ms
6,548 KB
testcase_26 AC 20 ms
6,548 KB
testcase_27 AC 104 ms
6,548 KB
testcase_28 AC 28 ms
6,548 KB
testcase_29 AC 9 ms
6,548 KB
testcase_30 AC 27 ms
6,548 KB
testcase_31 AC 53 ms
6,548 KB
testcase_32 AC 11 ms
6,548 KB
testcase_33 AC 9 ms
6,548 KB
testcase_34 AC 107 ms
6,548 KB
testcase_35 AC 8 ms
6,548 KB
testcase_36 AC 8 ms
6,548 KB
testcase_37 AC 4 ms
6,548 KB
testcase_38 AC 16 ms
6,548 KB
testcase_39 AC 27 ms
6,548 KB
testcase_40 AC 26 ms
6,548 KB
testcase_41 AC 17 ms
6,548 KB
testcase_42 AC 31 ms
6,548 KB
testcase_43 AC 5 ms
6,548 KB
testcase_44 AC 12 ms
6,548 KB
testcase_45 AC 74 ms
6,548 KB
testcase_46 AC 9 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using mint = modint998244353;
using ll = long long;
using lb = long double;
using VI = vector<int>;
using VL = vector<ll>;
using P = pair<int, int>;
inline void scan(){}
template<class Head,class... Tail>
inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);}
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define LB(...) lb __VA_ARGS__;scan(__VA_ARGS__)
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
template<class ll> inline bool chmax(ll& a, ll b) { if (a < b) { a = b; return 1; } return 0; }template<class ll> inline bool chmin(ll& a, ll b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>
std::istream &operator>>(std::istream&is,std::vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T>
std::ostream &operator<<(std::ostream&os,const std::vector<T>&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;}
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
//_
int n, k;
vector<ll> a;
vector<int> x;
int ans = 0;
void dfs(int v){
  x.push_back(v);
  if(x.size() == k){
    ll s1 = 0;
    mint s2 = 0;
    for(auto&& i : x){
      s1 += a[i];
      s2 += a[i];
      s1 %= 998;
    }
    if(s2.val() <= s1){
      ans++;
    }
  }else{
    rep(i, v + 1, n){
      dfs(i);
      x.pop_back();
    }
  }
}
int main(){
  cin >> n >> k;
  a.resize(n);
  cin >> a;
  rep(i, 0, n){
    dfs(i);
    //cout << x << endl;
    x.pop_back();
  }
  cout << ans % 998 << endl;
}
0