1 条题解

  • 1
    @ 2026-7-19 10:33:16
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n, q;
        cin >> n >> q;
        set<int> s;
        s.insert(0), s.insert(n);
        while(q--){
        	int c, x;
        	cin >> c >> x;
        	if(c == 2){
    			auto it = s.upper_bound(x);
    			int r = *it;
    			it--;
    			int l = *it;
    			cout << r - l << '\n'; 
    		}else{
    			s.insert(x);
    		}
    	} 
        return 0;
    }
    
    • 1

    信息

    ID
    421
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    164
    已通过
    75
    上传者