結果

問題 No.1017 Reiwa Sequence
ユーザー ShibuyapShibuyap
提出日時 2020-07-26 02:25:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,281 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 210,612 KB
実行使用メモリ 88,756 KB
最終ジャッジ日時 2023-09-10 02:57:00
合計ジャッジ時間 24,302 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 9 ms
4,996 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 10 ms
5,320 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 626 ms
71,052 KB
testcase_20 AC 592 ms
71,208 KB
testcase_21 AC 610 ms
71,000 KB
testcase_22 AC 567 ms
70,964 KB
testcase_23 AC 537 ms
70,988 KB
testcase_24 AC 568 ms
70,932 KB
testcase_25 AC 484 ms
70,932 KB
testcase_26 AC 391 ms
70,888 KB
testcase_27 AC 93 ms
17,752 KB
testcase_28 AC 119 ms
21,312 KB
testcase_29 AC 55 ms
12,732 KB
testcase_30 AC 19 ms
7,340 KB
testcase_31 AC 41 ms
11,948 KB
testcase_32 AC 39 ms
11,624 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 190 ms
36,584 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 219 ms
36,836 KB
testcase_39 AC 18 ms
7,320 KB
testcase_40 AC 70 ms
21,252 KB
testcase_41 AC 71 ms
21,192 KB
testcase_42 AC 68 ms
20,604 KB
testcase_43 AC 70 ms
20,760 KB
testcase_44 AC 622 ms
88,756 KB
testcase_45 AC 70 ms
20,840 KB
testcase_46 AC 68 ms
20,520 KB
testcase_47 AC 68 ms
20,392 KB
testcase_48 AC 161 ms
27,060 KB
testcase_49 AC 115 ms
32,064 KB
testcase_50 AC 68 ms
15,712 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 85 ms
19,760 KB
testcase_53 AC 537 ms
69,984 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    }
    
    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{
        dfs(i+1,j);
        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