結果
問題 | No.1515 Making Many Multiples |
ユーザー | milanis48663220 |
提出日時 | 2023-07-11 00:44:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,679 ms / 2,000 ms |
コード長 | 2,294 bytes |
コンパイル時間 | 1,429 ms |
コンパイル使用メモリ | 123,820 KB |
実行使用メモリ | 35,264 KB |
最終ジャッジ日時 | 2023-10-10 01:28:01 |
合計ジャッジ時間 | 23,777 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,352 KB |
testcase_02 | AC | 1,554 ms
35,264 KB |
testcase_03 | AC | 1,506 ms
35,216 KB |
testcase_04 | AC | 1,626 ms
35,000 KB |
testcase_05 | AC | 1,679 ms
35,176 KB |
testcase_06 | AC | 924 ms
35,240 KB |
testcase_07 | AC | 942 ms
35,200 KB |
testcase_08 | AC | 285 ms
10,716 KB |
testcase_09 | AC | 760 ms
25,236 KB |
testcase_10 | AC | 771 ms
25,712 KB |
testcase_11 | AC | 1,129 ms
29,460 KB |
testcase_12 | AC | 745 ms
23,324 KB |
testcase_13 | AC | 10 ms
4,352 KB |
testcase_14 | AC | 1,193 ms
31,232 KB |
testcase_15 | AC | 11 ms
4,348 KB |
testcase_16 | AC | 1,432 ms
33,876 KB |
testcase_17 | AC | 259 ms
25,696 KB |
testcase_18 | AC | 153 ms
29,124 KB |
testcase_19 | AC | 36 ms
20,556 KB |
testcase_20 | AC | 259 ms
19,884 KB |
testcase_21 | AC | 855 ms
34,412 KB |
testcase_22 | AC | 3 ms
4,348 KB |
testcase_23 | AC | 917 ms
34,736 KB |
testcase_24 | AC | 2 ms
4,352 KB |
testcase_25 | AC | 2 ms
4,348 KB |
testcase_26 | AC | 2 ms
4,352 KB |
testcase_27 | AC | 1,102 ms
34,732 KB |
testcase_28 | AC | 600 ms
35,080 KB |
testcase_29 | AC | 15 ms
4,896 KB |
testcase_30 | AC | 36 ms
4,604 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #include <atcoder/segtree> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } int op(int x, int y){ return max(x, y); } int e(){ return -1e9; } using Seg = atcoder::segtree<int, op, e>; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, k, x, y; cin >> n >> k >> x >> y; x%=k; y%=k; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; a[i]%=k; } vector<Seg> dp; for(int i = 0; i < k; i++) dp.push_back(Seg(k)); dp[x].set(y, 0); dp[y].set(x, 0); for(int i = 0; i < n; i++){ int rem = k-a[i]; for(int x = 0; x < k; x++){ int y = (rem+k-x)%k; dp[x].set(y, dp[x].get(y)+1); } vector<int> nx(k); for(int x = 0; x < k; x++){ nx[x] = dp[x].all_prod(); } for(int x = 0; x < k; x++){ int cur = dp[a[i]].get(x); if(nx[x] > cur){ dp[a[i]].set(x, nx[x]); dp[x].set(a[i], nx[x]); } } } int ans = 0; for(int x = 0; x < k; x++) chmax(ans, dp[x].all_prod()); cout << ans << endl; }