結果
問題 | No.1294 マウンテン数列 |
ユーザー |
![]() |
提出日時 | 2020-11-20 22:28:54 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 220 ms / 2,000 ms |
コード長 | 1,206 bytes |
コンパイル時間 | 1,074 ms |
コンパイル使用メモリ | 82,860 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 13:21:44 |
合計ジャッジ時間 | 3,317 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <iostream>#include <cstdio>#include <cmath>#include <ctime>#include <cstdlib>#include <cassert>#include <vector>#include <list>#include <stack>#include <queue>#include <deque>#include <map>#include <set>#include <bitset>#include <string>#include <algorithm>#include <utility>#include <complex>#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)#define chmin(x, y) (x) = min((x), (y))#define chmax(x, y) (x) = max((x), (y))#define all(x) (x).begin(),(x).end()#define inf 1e18#define mod 998244353using namespace std;typedef long long llint;typedef long long ll;typedef pair<llint, llint> P;ll n;ll a[2505], b[2505];ll dp[2505], sum[2505];int main(void){ios::sync_with_stdio(0);cin.tie(0);cin >> n;rep(i, 1, n) cin >> a[i];ll dmax = 0;rep(i, 1, n-1) chmax(dmax, a[i+1]-a[i]);rep(i, dmax, 2500){rep(j, 1, n) dp[j] = 0;rep(j, 1, n-1){ll p = lower_bound(a+1, a+n+1, a[j+1]-i) - a;dp[j] = sum[j-1] - sum[p-1] + 1, dp[j] %= mod;sum[j] = sum[j-1] + dp[j], sum[j] %= mod;}b[i] = dp[n-1]*2%mod;}ll ans = 0;rep(i, 1, 2500) ans += (b[i]-b[i-1]+mod)%mod * i % mod, ans %= mod;cout << ans << endl;return 0;}