結果

問題 No.1017 Reiwa Sequence
ユーザー ShibuyapShibuyap
提出日時 2020-07-26 02:27:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 210,156 KB
実行使用メモリ 814,328 KB
最終ジャッジ日時 2023-09-26 22:54:21
合計ジャッジ時間 21,359 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 8 ms
5,064 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 10 ms
5,392 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 663 ms
70,976 KB
testcase_20 AC 628 ms
71,036 KB
testcase_21 AC 624 ms
70,960 KB
testcase_22 AC 572 ms
70,940 KB
testcase_23 AC 538 ms
70,956 KB
testcase_24 AC 553 ms
70,960 KB
testcase_25 AC 490 ms
70,984 KB
testcase_26 AC 401 ms
71,012 KB
testcase_27 AC 95 ms
17,648 KB
testcase_28 AC 125 ms
21,328 KB
testcase_29 AC 58 ms
12,744 KB
testcase_30 AC 20 ms
7,400 KB
testcase_31 AC 45 ms
11,972 KB
testcase_32 AC 41 ms
11,688 KB
testcase_33 AC 5 ms
4,436 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 196 ms
36,684 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 244 ms
36,608 KB
testcase_39 AC 19 ms
7,420 KB
testcase_40 AC 81 ms
21,252 KB
testcase_41 AC 81 ms
21,168 KB
testcase_42 AC 78 ms
20,328 KB
testcase_43 AC 79 ms
21,032 KB
testcase_44 WA -
testcase_45 AC 80 ms
21,104 KB
testcase_46 AC 79 ms
20,492 KB
testcase_47 WA -
testcase_48 MLE -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int ans[MAX_N];
int a[MAX_N];
int n;
int ok = 0;

map<int,vector<int>> mp;
vector<int> tmp;
int x;

void dfs(int i, int j){
    if(ok)return;
    if(i == n || j >= 22){
        return;
    }
    dfs(i+1,j);
    int y = x + a[i];
    int xx = x;
    if(mp.find(y) != mp.end()){
        ok = 1;
        vector<int> keep = mp[y];
        tmp.push_back(i);

        rep(i,keep.size()){
            ans[keep[i]]++;
        }

        rep(i,tmp.size()){
            ans[tmp[i]]--;
        }

        return;
    }else{
        x = y;
        tmp.push_back(i);
        mp[y] = tmp;
        dfs(i+1,j+1);
    }

    x = xx;
    tmp.erase(tmp.end()-1);

}

int main() {
    cin >> n;
    rep(i,n)cin >> a[i];

    dfs(0,0);

    if(ok == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        rep(i,n){
            cout << a[i] * ans[i];
            if(i == n - 1) cout << endl;
            else cout << " ";
        }
    }

    return 0;
}
 
 
0