結果
| 問題 | No.1238 選抜クラス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-25 21:50:43 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 3,227 bytes |
| 記録 | |
| コンパイル時間 | 1,150 ms |
| コンパイル使用メモリ | 211,044 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2026-06-14 00:27:44 |
| 合計ジャッジ時間 | 2,952 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
In function 'void std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = Mod_Int<1000000007>*; _Tp = int]',
inlined from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = Mod_Int<1000000007>*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:979:21,
inlined from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = Mod_Int<1000000007>*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:1011:20,
inlined from 'int main()' at main.cpp:118:9:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:925:9: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified size between 18446400459146162440 and 18446744073709391608 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
925 | *__first = __val;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};
template<int mod>
struct Mod_Int{
ll x;
Mod_Int() : x(0) {}
Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
Mod_Int &operator += (const Mod_Int &p){
x = (x + p.x) % mod;
return *this;
}
Mod_Int &operator -= (const Mod_Int &p){
x = (x + mod - p.x) % mod;
return *this;
}
Mod_Int &operator *= (const Mod_Int &p){
x = (x * p.x) % mod;
return *this;
}
Mod_Int &operator /= (const Mod_Int &p){
*this *= p.inverse();
return *this;
}
Mod_Int &operator ++ () {return *this += Mod_Int(1);}
Mod_Int operator ++ (int){
Mod_Int tmp = *this;
++*this;
return tmp;
}
Mod_Int &operator -- () {return *this -= Mod_Int(1);}
Mod_Int operator -- (int){
Mod_Int tmp = *this;
--*this;
return tmp;
}
Mod_Int operator - () const {return Mod_Int(-x);}
Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}
Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}
Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}
Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}
bool operator == (const Mod_Int &p) const {return x == p.x;}
bool operator != (const Mod_Int &p) const {return x != p.x;}
Mod_Int inverse() const {
assert(*this != Mod_Int(0));
return pow(mod-2);
}
Mod_Int pow(ll k) const{
Mod_Int now = *this, ret = 1;
while(k){
if(k&1) ret *= now;
now *= now, k >>= 1;
}
return ret;
}
friend ostream &operator << (ostream &os, const Mod_Int &p){
return os << p.x;
}
friend istream &operator >> (istream &is, Mod_Int &p){
ll a;
is >> a;
p = Mod_Int<mod>(a);
return is;
}
};
using mint = Mod_Int<MOD>;
int main(){
int N, K;
cin >> N >> K;
int A[N];
rep(i, N) cin >> A[i];
mint dp[N+1][20001];
fill(dp[0], dp[N+1], 0);
dp[0][10000] = 1;
rep(i, N){
rep(j, 20001){
dp[i+1][j] += dp[i][j];
int nj = j+A[i]-K;
if(0 <= nj && nj <= 20000) dp[i+1][nj] += dp[i][j];
}
}
mint ans = -1;
rep2(i, 10000, 20000) ans += dp[N][i];
cout << ans << endl;
}