結果

問題 No.2561 みんな大好きmod 998
ユーザー Pres1dent
提出日時 2023-12-02 17:11:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 3,521 ms
コンパイル使用メモリ 165,532 KB
最終ジャッジ日時 2025-02-18 05:55:58
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 1 WA * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
// S_1 = ((1), (2), ..., (m))
// S_2 = ((1, 1), (1, 2), ..., (m, m))
using mint = modint998244353;
int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> p(n);
  for (int i = 0; i < k; i++) { p[i] = 1; }
  sort(p.begin(), p.end());
  int cnt = 0;
  do {
    long long s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
      if (p[i]) {
        s1 += a[i];
        s2 += a[i];
        s1 %= 998244353;
        s2 %= 998;
      }
    }
    if (s2 <= s1) cnt++;
  } while (next_permutation(p.begin(), p.end()));
  cout << cnt % 998 << endl;

}
0