結果

問題 No.3184 Make Same
ユーザー t98slider
提出日時 2025-06-20 21:39:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 208,816 KB
実行使用メモリ 14,372 KB
最終ジャッジ日時 2025-06-20 21:39:33
合計ジャッジ時間 12,962 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 2 TLE * 2 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto &&v : a) cin >> v;
    auto b = a;
    b.erase(unique(b.begin(), b.end()), b.end());
    vector<tuple<int,int,int>> ans;
    while(b.size() >= 2){
        int mid = b.size() / 2;
        ll th = b[mid];
        ll v = th - b[0];
        ans.emplace_back(1, 0, v);
        for(int i = 0; i < n; i++){
            if(a[i] < th){
                a[i] += v;
                get<1>(ans.back()) = i + 1;
            }
        }
        sort(a.begin(), a.end());
        b = a;
        b.erase(unique(b.begin(), b.end()), b.end());
    }
    for(auto [l, r, v] : ans) cout << l << " " << r << " " << v << '\n';
}
0