/* -*- coding: utf-8 -*- * * 3324.cc: No.3324 繝上う繝ゥ繧、繝亥虚逕サ - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_M = 200000; /* typedef */ using pii = pair; using vpii = vector; /* global variables */ int as[MAX_M]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) scanf("%d", as + i); vpii fs; for (int i = 0; i < m;) { int j = i++; while (i < n && as[i - 1] + 1 == as[i]) i++; fs.push_back({as[j], i - j}); } printf("%d\n", (int)fs.size()); for (auto [si, li]: fs) printf("%d %d\n", si, li); return 0; }