結果
| 問題 |
No.1825 Except One
|
| コンテスト | |
| ユーザー |
dekomori_sanae
|
| 提出日時 | 2022-01-28 22:31:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,693 bytes |
| コンパイル時間 | 1,098 ms |
| コンパイル使用メモリ | 90,220 KB |
| 実行使用メモリ | 104,780 KB |
| 最終ジャッジ日時 | 2024-12-30 08:30:32 |
| 合計ジャッジ時間 | 3,351 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 8 WA * 23 |
ソースコード
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
ll dp[51][51][5001]; // dp[i][j][k] : i項目までで、j個選んで、総和がkとなる場合の数
int main() {
ll n;
cin >> n;
vl a(n);
rep(i, n) {
cin >> a[i];
}
sort(all(a));
dp[0][0][0] = 1;
rep(i, n) {
exrep(j, 0, n-1) {
exrep(k, 0, 100*n) {
// a[i]を選ばないとき
dp[i+1][j][k] += dp[i][j][k];
// a[i]を選ぶとき
if(k + a[i] <= 100*n) {
dp[i+1][j+1][k + a[i]] += dp[i][j][k];
}
}
}
}
ll ans = n * (n - 1) / 2;
exrep(i, 2, n-1) { // a[i]を末尾の要素とする
exrep(j, 2, n) {
exrep(k, 0, 100*n) {
if(k == (j - 1) * a[i]) {
ans += dp[i][j][k];
}
}
}
}
out(ans);
re0;
}
dekomori_sanae