diff --git a/Luogu/T263082/T263082.cpp b/Luogu/T263082/T263082.cpp new file mode 100644 index 00000000..46bc632e --- /dev/null +++ b/Luogu/T263082/T263082.cpp @@ -0,0 +1,42 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e5 + 5; + +int n, a[N], b[N]; +std::vector> ans; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + + b[i] = a[i] - a[i - 1]; + } + + b[n + 1] = -a[n]; + + for (int i = 1, j = 1; i <= n + 1; i++) { + while (b[i] < 0) { + while (j < i && b[j] <= 0) j++; + b[j]--, b[i]++; + ans.emplace_back(j, i - 1); + } + } + + cout << ans.size() << endl; + + for (const auto &e : ans) { + cout << e.first << ' ' << e.second << endl; + } + + return 0; +} diff --git a/Luogu/T263082/samples/checker.cpp b/Luogu/T263082/samples/checker.cpp new file mode 100644 index 00000000..b8837872 --- /dev/null +++ b/Luogu/T263082/samples/checker.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dc2deaf39feaa34c1b2a1771424b2185e9b622d2a68256131f9248262419f1b +size 990 diff --git a/Luogu/T263082/samples/range.in b/Luogu/T263082/samples/range.in new file mode 100644 index 00000000..75956587 --- /dev/null +++ b/Luogu/T263082/samples/range.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7cbefb59ebe4f9188ed25e9163c4861b27bccf6725b18d8839c2328bdf6645c9 +size 174906 diff --git a/Luogu/T263082/samples/range.out b/Luogu/T263082/samples/range.out new file mode 100644 index 00000000..86c56a59 --- /dev/null +++ b/Luogu/T263082/samples/range.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1703a30e470fed8ff8c85516433baf9dd7f9e4aa5ea43dbde1c0ea5b1de9a36 +size 589946