Hello everyone,
Today I attempted Google Kickstart 2020 Round F and I have to say I failed terribly. I got stucked to one question which was the easiest among 4 questions. I am talking about question#1 ATM Queue. After the contest has ended, I saw other's solutions and found out that I also solved the question in 40 mins but was getting Memory Limit Exceeded Error.
Can anyone point out why I am getting this error. Below is my solution -
#include <bits/stdc++.h>
using namespace std;
bool mycomp(pair<int, int> const& val1, pair<int, int> const& val2){
if(val1.first == val2.first)
return val1.second < val2.second;
return val1.first < val2.first;
};
int main(){
int t;
cin>>t;
int count = 1;
while(count <= t){
int n, x;
cin>>n>>x;
vector<pair<int, int>> quo(n);
for(int i=0; i<n; i++){
int num;
quo[i] = make_pair(num/x, i);
}
sort(quo.begin(), quo.end());
cout<<"Case #"<<count<<": ";
for(int i=0; i<n; i++)
cout<<quo[i].second+1<<" ";
}
}Link to Google Kickstart 2020 - https://codingcompetitions.withgoogle.com/kickstart