結果

問題 No.3184 Make Same
ユーザー D M
提出日時 2025-07-17 10:25:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 6,204 ms
コンパイル使用メモリ 335,668 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-17 10:26:10
合計ジャッジ時間 22,219 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 998244353;
#include<atcoder/all>
using namespace atcoder;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> ans;
  while (a[0]!=a[n-1]){
    ll l=a[0], r=a[n-1];
    ll m=(l+r)/2;
    auto it = upper_bound(all(a), m);
    rep(i,it-a.begin()) {
      a[i]+=r-m;
    }
    ans.push_back({0, it-a.begin(), r-m});
    sort(all(a));
  }
  cout << ans.size() << endl;
  for (auto& v : ans) {
    cout << 1 << " " << v[1] << " " << v[2] << endl;
  }
}
0