結果
| 問題 | No.674 n連勤 | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2018-04-19 15:17:28 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 23 ms / 2,000 ms | 
| コード長 | 1,267 bytes | 
| コンパイル時間 | 1,356 ms | 
| コンパイル使用メモリ | 92,664 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 04:46:51 | 
| 合計ジャッジ時間 | 2,179 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |   scanf("%lld%d", &d, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:54:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |     scanf("%lld%lld", &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 674.cc: No.674 n連勤 - yukicoder
 */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
/* constant */
/* typedef */
typedef long long ll;
typedef pair<ll,ll> pll;
typedef set<pll> spll;
/* global variables */
spll rs;
/* subroutines */
inline void setmin(ll &a, ll b) { if (a > b) a = b; }
inline void setmax(ll &a, ll b) { if (a < b) a = b; }
/* main */
int main() {
  ll d;
  int q;
  scanf("%lld%d", &d, &q);
  ll maxl = 0;
  while (q--) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    b++;
    pll qr(a, b);
    spll::iterator sit = rs.lower_bound(qr);
    if (sit != rs.begin()) sit--;
    while (sit != rs.end() && sit->first <= qr.second) {
      ll ai = sit->first, bi = sit->second;
      spll::iterator eit = sit++;
      if (qr.first <= bi) {
	setmin(qr.first, ai);
	setmax(qr.second, bi);
	rs.erase(eit);
      }
    }
    rs.insert(qr);
    setmax(maxl, qr.second - qr.first);
    printf("%lld\n", maxl);
  }
  return 0;
}
            
            
            
        