結果
問題 | No.674 n連勤 |
ユーザー |
![]() |
提出日時 | 2020-10-15 22:29:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 2,054 ms |
コンパイル使用メモリ | 175,736 KB |
実行使用メモリ | 10,172 KB |
最終ジャッジ日時 | 2024-07-20 20:02:56 |
合計ジャッジ時間 | 3,609 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using ul = unsigned long;using ull = unsigned long long;template<class T> inline bool chmax(T& a, T b){if (a < b)a = b;return a < b;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);ll d, q;cin >> d >> q;vector<ll> a(q), b(q);set<ll> s;for (ll i = 0; i < q; ++i){cin >> a[i] >> b[i];s.insert(a[i] - 1);s.insert(a[i]);s.insert(b[i]);s.insert(b[i] + 1);}stringstream ss;ll maxd{ 0 };for (int i = 0; i < q; ++i){auto itb = s.lower_bound(a[i]);auto ite = s.upper_bound(b[i]);ite = s.erase(itb, ite);auto it = ite;chmax(maxd, *ite - *(--it) - 1);ss << maxd << "\n";}cout << ss.str();return 0;}