結果
| 問題 |
No.2667 Constrained Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-08 22:54:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 1,981 ms |
| コンパイル使用メモリ | 203,464 KB |
| 最終ジャッジ日時 | 2025-02-20 02:52:33 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 42 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
map<int,int> L;
map<int,int,greater<>> R;
for(int i=0; i<N; i++){
int l,r; cin >> l >> r;
L[l-N]++; R[r-1]++;
}
int maxl = -1e9,minr = 2e9;
for(auto [k,v] : L){
if(v >= 2) L[k+1] += v-1;
if(v) maxl = max(maxl,k);
}
for(auto [k,v] : R){
if(v >= 2) R[k-1] += v-1;
if(v) minr = min(minr,k);
}
cout << max(0,minr-maxl+1) << endl;
}