結果

問題 No.1515 Making Many Multiples
ユーザー momoyuumomoyuu
提出日時 2023-04-28 14:13:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,109 bytes
コンパイル時間 3,689 ms
コンパイル使用メモリ 266,380 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-04-28 19:32:47
合計ジャッジ時間 5,560 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 16 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 34 ms
19,200 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 1 ms
6,944 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define chmax(a,b) a = max(a,b)

pair<int,int> calc(int a,int b){
    return make_pair(min(a,b),max(a,b));
}
int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    vector<int> a(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    map<pair<int,int>,int> d;
    vector<int> b(n+2);
    x %= k;
    y %= k;
    b[0] = x % k;
    b[1] = y % k;
    for(int i = 0;i<n;i++) b[i+2] = a[i] % k;
    unordered_map<int,set<pair<int,int>>>s;
    d[make_pair(min(x,y),max(x,y))] = 0;
    s[(x+y)%k].insert(make_pair(min(x,y),max(x,y)));
    int ans = 0;
    vector<vector<int>> tmp(n+2,vector<int>(k+1,-1e9));
    tmp[0][y] = 0;
    tmp[1][x] = 0;
    vector<int> cnt(n+2,0);
    for(int i = 0;i<n;i++){
        int now = b[i+2];
        for(int j = 0;j<i+2;j++){
            int nxt = b[j];
            int need = 2 * k - nxt - now;
            need %= k;
            int can = max(tmp[j][need]+1,cnt[j]);
            chmax(tmp[i+2][nxt],can);chmax(cnt[i+2],can);chmax(tmp[i+2][need],can);
            ans = max(ans,can);
        }
    }
    cout<<ans<<endl;
}
0