Submission #1216580

#TimeUsernameProblemLanguageResultExecution timeMemory
1216580kokoxuyaThe short shank; Redemption (BOI21_prison)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ss second
#define ff first
#define piii pair<int,pii>
#define debu(x) (cerr << #x  << " = "<< x << "\n")
#define debu2(x,y) (cerr << #x  << " = "<< x << " " << #y << " = " << y << "\n")
#define debu3(x,y,z) (cerr << #x  << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n")
#define bitout(x,y) {\
	cerr << #x << " : ";\
	for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\
	cout << "\n";\
}
#define rangeout(j,rangestart,rangeend) {\
	cerr << "outputting" << #j<< ":\n";\
	for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\
	cerr<<"\n";\
}
#define c1 {cerr << "Checkpoint 1! \n\n";cerr.flush();}
#define c2 {cerr << "Checkpoint 2! \n\n";cerr.flush();}
#define c3 {cerr << "Checkpoint 3! \n\n";cerr.flush();}
#define c4 {cerr << "Checkpoint 4! \n\n";cerr.flush();}


signed main()
{
    int t1,t2,t3,t4;
    mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int n,d,t;cin>>n>>d>>t;
	
	priority_queue<piii,vector<piii>,greater<piii>>pq;
	for(int a=1;a<=n;a++)
	{
		cin>>t1;
		if(t1<=t)pq.push(mp(a,mp(a+(t-t1),a)));
	}
	
	set<int>curr;
	priority_queue<pii,vector<pii>,greater<pii>>ends;
	vector<int>foreach(n+1,0);
	int tots=0;
	for(int a=1;a<=n;a++)
	{
		while(!pq.empty()&&pq.top().ff<=a)
		{
			curr.insert(pq.top().ss.ss);
			ends.push(mp(pq.top().ss));
			pq.pop();
		}
		while(!ends.empty()&&ends.top().ff<a)
		{
			curr.erase(ends.top().ss);
			ends.pop();
		}
		
		if(!curr.empty())
		{
			tots++;
			foreach[a]=(*curr.begin());
		}
	}
	
	int ans=0,currans=0;
	priority_queue<int>hav;
	for(int a=1;a<=n;a++)
	{
		currans+=(foreach[a]==0?0:1);
	}
	
	for(int a=n;a>=1;a--)
	{
		if(foreach[a]!=0)currans--;
		hav.push(foreach[a]);
		
		while(!foreach.empty()&&foreach.top()>=a)
		{
			foreach.pop();
			currans++;
		}
		ans=max(ans,currans);
	}
	
	cout<<(tots-ans);
}


Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:53:37: error: no matching function for call to 'make_pair(const std::pair<long long int, long long int>&)'
   53 |                         ends.push(mp(pq.top().ss));
      |                                     ^
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from prison.cpp:1:
/usr/include/c++/11/bits/stl_pair.h:567:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
/usr/include/c++/11/bits/stl_pair.h:567:5: note:   template argument deduction/substitution failed:
prison.cpp:53:37: note:   candidate expects 2 arguments, 1 provided
   53 |                         ends.push(mp(pq.top().ss));
      |                                     ^
prison.cpp:81:49: error: 'class std::vector<long long int>' has no member named 'top'
   81 |                 while(!foreach.empty()&&foreach.top()>=a)
      |                                                 ^~~
prison.cpp:83:33: error: 'class std::vector<long long int>' has no member named 'pop'
   83 |                         foreach.pop();
      |                                 ^~~