結果

問題 No.1017 Reiwa Sequence
ユーザー やむなくやむなく
提出日時 2020-04-03 21:56:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,695 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 180,952 KB
実行使用メモリ 14,256 KB
最終ジャッジ日時 2023-09-16 01:20:57
合計ジャッジ時間 15,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 166 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 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,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 109 ms
4,376 KB
testcase_15 AC 112 ms
4,376 KB
testcase_16 AC 109 ms
4,380 KB
testcase_17 AC 107 ms
4,380 KB
testcase_18 AC 110 ms
4,376 KB
testcase_19 AC 101 ms
4,380 KB
testcase_20 AC 102 ms
4,380 KB
testcase_21 AC 100 ms
4,380 KB
testcase_22 AC 100 ms
4,380 KB
testcase_23 AC 99 ms
4,380 KB
testcase_24 AC 98 ms
4,380 KB
testcase_25 AC 98 ms
4,380 KB
testcase_26 AC 98 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 27 ms
4,384 KB
testcase_31 WA -
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 10 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 9 ms
4,380 KB
testcase_38 AC 9 ms
4,380 KB
testcase_39 AC 9 ms
4,376 KB
testcase_40 AC 74 ms
9,864 KB
testcase_41 AC 74 ms
9,976 KB
testcase_42 AC 71 ms
9,792 KB
testcase_43 AC 72 ms
9,896 KB
testcase_44 AC 75 ms
9,756 KB
testcase_45 AC 75 ms
9,908 KB
testcase_46 AC 72 ms
9,568 KB
testcase_47 AC 72 ms
9,596 KB
testcase_48 AC 16 ms
6,464 KB
testcase_49 AC 117 ms
14,256 KB
testcase_50 AC 16 ms
6,476 KB
testcase_51 AC 338 ms
4,376 KB
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// Created by yamunaku on 2020/04/03.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

unsigned long long xor128(){
    static unsigned long long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long long t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int main(){
    //CFS;
    int n;
    cin >> n;
    map<int, int> mp;
    vi a(n);
    vector<pair<ll, int>> p(n);
    rep(i, n){
        cin >> a[i];
        p[i] = {a[i], i};
        auto itr = mp.find(a[i]);
        if(itr != mp.end()){
            CYES;
            vi ans(n, 0);
            ans[i] = a[i], ans[itr->second] = -a[i];
            rep(j, n){
                cout << ans[j] << " ";
            }
            cout << endl;
            return 0;
        }
        mp[a[i]] = i;
    }
    sort(all(p), greater<pair<ll, int>>());
    vi tmp;
    int kk = 1e7/n;
    rep(t, kk){
        ll sum = 0;
        tmp = vi(n, 0);
        rep(i, n){
            if(sum > 0){
                if(sum - p[i].first == 0){
                    tmp[i] = -1;
                    goto next;
                }else{
                    if(xor128() % 2){
                        tmp[i] = -1;
                        sum -= p[i].first;
                    }
                }
            }else{
                if(sum + p[i].first == 0){
                    tmp[i] = 1;
                    goto next;
                }else{
                    if(xor128() % 2){
                        tmp[i] = 1;
                        sum += p[i].first;
                    }
                }
            }
        }
    }
    CNO;
    return 0;
    next:;
    CYES;
    vi ans(n, 0);
    rep(i, n){
        ans[p[i].second] = tmp[i] * p[i].first;
    }
    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}
0