四大文化赛道完整展开
03-execution/run-002/source-snapshot/main.cpp
main.cpp
站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。
文件类型.cpp
10-cases/s2-jh-07-broadcast-wave/03-execution/run-002/source-snapshot/main.cpp
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, timeline;
if (!(cin >> n >> timeline)) {
return 0;
}
vector<long long> diff(timeline + 3, 0);
for (int i = 0; i < n; ++i) {
int left, right;
cin >> left >> right;
++diff[left];
--diff[right + 1];
}
long long active = 0;
long long covered = 0;
long long peak = -1;
int first_peak = 0;
for (int minute = 0; minute <= timeline; ++minute) {
active += diff[minute];
if (active > 0) {
++covered;
}
if (active > peak) {
peak = active;
first_peak = minute;
}
}
cout << "covered=" << covered << "\n";
cout << "peak=" << peak << "\n";
cout << "first_peak=" << first_peak << "\n";
return 0;
}