結果

問題 No.318 学学学学学
ユーザー mamekinmamekin
提出日時 2015-12-20 09:07:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 98,732 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 14:05:36
合計ジャッジ時間 6,596 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,348 KB
testcase_01 AC 12 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 10 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 AC 58 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 51 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int> > p(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        p[i] = make_pair(a[i], i);
    }

    sort(p.rbegin(), p.rend());
    for(int i=0; i<n-1; ++i){
        int b = p[i].first;
        if(b != p[i+1].first)
            continue;

        int x = p[i].second;
        int y = p[i+1].second;
        if(a[x] != b || a[y] != b)
            continue;

        for(int i=y; i<=x; ++i)
            a[i] = b;
    }

    cout << a[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << a[i];
    cout << endl;

    return 0;
}
0