結果

問題 No.3324 ハイライト動画
コンテスト
ユーザー elphe
提出日時 2025-08-22 10:16:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 2,782 ms
コンパイル使用メモリ 280,948 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-01 14:30:34
合計ジャッジ時間 4,402 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

[[nodiscard]] static inline constexpr std::vector<std::pair<uint_least32_t, uint_least32_t>> solve([[maybe_unused]] 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 cur_first = A[0], cur_length = 1;
	for (uint_fast32_t i = 1; i != M; ++i)
	{
		if (A[i - 1] + 1 == A[i])
			++cur_length;
		else
			ans.emplace_back(cur_first, cur_length), cur_first = A[i], cur_length = 1;
	}

	ans.emplace_back(cur_first, cur_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;
}
0