結果

問題 No.1294 マウンテン数列
ユーザー leaf_1415leaf_1415
提出日時 2020-11-20 22:28:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 81,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 19:34:40
合計ジャッジ時間 3,551 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 22 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 195 ms
4,376 KB
testcase_11 AC 194 ms
4,376 KB
testcase_12 AC 194 ms
4,376 KB
testcase_13 AC 191 ms
4,380 KB
testcase_14 AC 161 ms
4,376 KB
testcase_15 AC 184 ms
4,380 KB
testcase_16 AC 161 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 998244353

using 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;
}
0