Solution for CCC '15 S3 - Gates in C++

Aug. 3, 2020 0.210398 seconds C++
#include <bits/stdc++.h>
using namespace std;

typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl;
typedef queue<int> qi;
typedef queue<char> qc;
typedef stack<int> si;
typedef stack<char> sc;
#define F first
#define S second
#define PB push_back

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	bitset<100005> taken;
	int g, p;
	cin >> g >> p;
	int temp, temp2;
	for(int i = 0; i < p; i++){
		cin >> temp;
		temp2 = taken._Find_next(g - temp);
		if(temp2 > g){
			cout << i;
			return 0;
		taken[temp2] = 0;
	cout << p;
    return 0;


No editorial for this problem. :(

Original Problem

You can view the original page for this problem on the DMOJ.