結果
問題 |
No.3184 Make Same
|
ユーザー |
|
提出日時 | 2025-06-20 21:44:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 330 ms / 2,000 ms |
コード長 | 1,037 bytes |
コンパイル時間 | 1,902 ms |
コンパイル使用メモリ | 206,616 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 21:45:20 |
合計ジャッジ時間 | 14,601 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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; vector<tuple<int,int,int>> ans; for(int i = 29; i >= 0; i--){ int add = 1 << i; if(a[0] + add > a.back()) continue; ans.emplace_back(1, 0, add); for(int i = 0; i < n; i++){ if(a[i] + add <= a.back()){ a[i] += add; get<1>(ans.back()) = i + 1; } } sort(a.begin(), a.end()); } cout << ans.size() << '\n'; for(auto [l, r, v] : ans) cout << l << " " << r << " " << v << '\n'; }