結果
問題 |
No.3184 Make Same
|
ユーザー |
![]() |
提出日時 | 2025-06-24 16:53:21 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 420 ms / 2,000 ms |
コード長 | 2,079 bytes |
コンパイル時間 | 1,882 ms |
コンパイル使用メモリ | 149,512 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-24 16:53:42 |
合計ジャッジ時間 | 19,202 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> #include <cmath> #include <iterator> using namespace std; using i64 = int64_t; template<class T> using VV = vector<vector<T>>; #define REP(i, n) for(i64 i = 0; i < i64(n); i++) #define REP1(i, n) for(i64 i = 1; i <= i64(n); i++) i64 INF = 100100100100100L; i64 direct[8][2] = { {1, 0}, {0, -1}, {-1, 0}, {0, 1}, {1, -1}, {-1, -1}, {-1, 1}, {1, 1} }; template<class T, class S> ostream &operator<<(ostream &os, pair<T, S> p); template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for(i64 i = 0; i < i64(v.size()); i++) { if (i > 0) os << ' '; os << v[i]; } return os; } template<class T> ostream &operator<<(ostream &os, const set<T> &st) { bool first = true; for(const T &it: st) if (first) { first = false; os << it; } else{ os << ' ' << it; } return os; } template<class T, class S> ostream &operator<<(ostream &os, map<T, S> &mp) { bool first = true; for(const auto &[f, l]: mp) if (first) { first = false; os << '{' << f << "-> " << l << '}'; } else{ os << ", {" << f << "-> " << l << '}'; } return os; } template<class T, class S> ostream &operator<<(ostream &os, pair<T, S> p) { os << '{' << p.first << ", " << p.second << '}'; return os; } struct LRU { i64 l; i64 r; i64 u; }; int main() { i64 N; cin >> N; vector<i64> A(N); for(i64 &it: A) cin >> it; vector<LRU> ans; i64 Q = 30; while (Q--) { i64 mid = (A.front() + A.back()) / 2; i64 p = upper_bound(A.begin(), A.end(), mid) - A.begin(); if (p > 0) p--; i64 add = A.back() - A[p]; ans.push_back({1, p + 1, add}); for(i64 i = 0; i <= p; i++) A[i] += add; sort(A.begin(), A.end()); if (A.front() == A.back()) { cout << ans.size() << endl; for(auto [l, r, u]: ans) { cout << l << ' ' << r << ' ' << u << endl; } return 0; } } exit(1); return 0; }