結果

問題 No.1294 マウンテン数列
ユーザー leaf_1415leaf_1415
提出日時 2020-11-20 22:28:54
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 503 ms
使用メモリ 9,712 KB
最終ジャッジ日時 2023-02-23 19:01:43
合計ジャッジ時間 2,903 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
9,688 KB
testcase_01 AC 2 ms
7,608 KB
testcase_02 AC 2 ms
9,692 KB
testcase_03 AC 1 ms
7,676 KB
testcase_04 AC 2 ms
7,720 KB
testcase_05 AC 12 ms
9,700 KB
testcase_06 AC 20 ms
7,600 KB
testcase_07 AC 1 ms
9,712 KB
testcase_08 AC 1 ms
9,676 KB
testcase_09 AC 2 ms
9,692 KB
testcase_10 AC 184 ms
7,596 KB
testcase_11 AC 179 ms
7,672 KB
testcase_12 AC 181 ms
7,596 KB
testcase_13 AC 175 ms
9,684 KB
testcase_14 AC 141 ms
9,708 KB
testcase_15 AC 168 ms
7,672 KB
testcase_16 AC 149 ms
7,656 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