結果
問題 | No.674 n連勤 |
ユーザー |
|
提出日時 | 2020-03-05 09:23:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 73,448 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 00:47:10 |
合計ジャッジ時間 | 1,927 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<set> using namespace std; long D; int Q; set<pair<long,long> >S; main() { cin>>D>>Q; long ans=0; for(int i=0;i<Q;i++) { long A,B;cin>>A>>B; B++; pair<long,long>now=make_pair(A,B); set<pair<long,long> >::iterator it=S.lower_bound(make_pair(A,-1L)); while(it!=S.end()&&it->first<=now.second) { if(now.second<it->second)now.second=it->second; it=S.erase(it); } while(it!=S.begin()) { it--; if(now.first>it->second)break; if(now.second<it->second)now.second=it->second; if(now.first>it->first)now.first=it->first; it=S.erase(it); } if(ans<now.second-now.first)ans=now.second-now.first; S.insert(now); cout<<ans<<endl; } }