結果
| 問題 |
No.3324 ハイライト動画
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-22 11:41:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,300 ms / 2,000 ms |
| コード長 | 1,019 bytes |
| コンパイル時間 | 2,853 ms |
| コンパイル使用メモリ | 281,080 KB |
| 実行使用メモリ | 7,724 KB |
| 最終ジャッジ日時 | 2025-11-01 14:31:18 |
| 合計ジャッジ時間 | 20,589 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
// O(N + M) 解法
[[nodiscard]] static inline constexpr std::vector<std::pair<uint_least32_t, uint_least32_t>> solve(const uint_fast32_t N, const uint_fast32_t M, const std::vector<uint_least32_t>& A) noexcept
{
std::vector<std::pair<uint_least32_t, uint_least32_t>> ans;
ans.reserve(M);
uint_fast32_t i, j, length;
for (i = 1, j = 0, length = 0; i <= N; ++i)
{
if (j != M && i == A[j]) ++length, ++j;
else if (length != 0) ans.emplace_back(i - length, length), length = 0;
}
if (length != 0) ans.emplace_back(i - length, length);
return ans;
}
static inline void output(const std::vector<std::pair<uint_least32_t, uint_least32_t>>& ans) noexcept
{
std::cout << ans.size() << '\n';
for (const auto& [S, L] : ans)
std::cout << S << ' ' << L << '\n';
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast32_t N, M;
std::cin >> N >> M;
std::vector<uint_least32_t> A(M);
for (auto& a : A) std::cin >> a;
output(solve(N, M, A));
return 0;
}