online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include<bits/stdc++.h> #define ll long long using namespace std; int main() { int t=0; cin>>t; while(t--) { ll n=0; ll vac=0; cin>>n>>vac; ll a[n]={0}; for(ll i=0;i<n;i++) { cin>>a[i]; } //sorting array sort(a,a+n); //case: when vaccine is greater than country having highest no. of infected population if(vac>=a[n-1]) { cout<<n<<endl; continue; } // all the other cases else { ll pos=0; // for finding the correct position from where we have to count no. of days ll days=0; for(ll i=0;i<n;i++) { if(a[i]>=vac) { pos=i;// for eg. lets i=4, when the condition is satisified break;// that means country at a[0],a[1],a[2],a[3] can be //cured in 4 days after rest of the countries are cured. } } days=pos; //so we assign same to the days from above loop result. while(pos<n) { days++;// since days=0, so day 1,2,3,..... if(a[pos]<=vac) { vac=a[pos]; pos++; } vac=vac*2; } cout<<days<<endl; } } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue