結果
| 問題 |
No.674 n連勤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-21 15:41:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 993 bytes |
| コンパイル時間 | 2,581 ms |
| コンパイル使用メモリ | 204,548 KB |
| 最終ジャッジ日時 | 2025-01-15 12:14:14 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:22: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=]
18 | int q; scanf("%*lld%d",&q);
| ^~~~~~~~~
main.cpp:18:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | int q; scanf("%*lld%d",&q);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:23:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | interval<lint> J; scanf("%lld%lld",&J.l,&J.r); J.r++;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const long long INF=1LL<<61;
template<class T> struct interval{
T l,r;
interval(){}
interval(const T& l,const T& r):l(l),r(r){}
bool operator<(const interval& I)const{ return make_tuple(l,r)<make_tuple(I.l,I.r); }
};
int main(){
int q; scanf("%*lld%d",&q);
multiset<lint> Sz;
set<interval<lint>> I;
rep(_,q){
interval<lint> J; scanf("%lld%lld",&J.l,&J.r); J.r++;
auto del=[&](auto it){
Sz.erase(Sz.find((it->r)-(it->l)));
I.erase(it);
};
auto add=[&](auto J){
Sz.emplace(J.r-J.l);
I.emplace(J);
};
while(1){
auto it=I.upper_bound(interval<lint>(J.l-1,INF));
if(it==I.end() || J.r<(it->l)) break;
J.r=max(J.r,it->r);
del(it);
}
while(1){
auto it=I.lower_bound(J);
if(it==I.begin()) break;
--it;
if((it->r)<J.l) break;
J.l=min(J.l,it->l);
del(it);
}
add(J);
printf("%lld\n",*Sz.rbegin());
}
return 0;
}