d.push_back(d.front());
d.pop_front();
why is this causing “SIGTERM” error ?
logic → I want to move the first element at the back of the deque.
complete program →
#include <bits/stdc++.h>
using namespace std;
#define PLL pair<long long, long long>
#define ll long long int
int main()
{
ll n, m;
cin >> n >> m;
deque<PLL> d(n);
ll i = 1;
for (auto &x : d)
{
cin >> x.first;
x.second = i;
i++;
}
ll ans = 0;
while(true)
{
if (d.size() == 1)
{
cout << d.front().second << endl;
return 0;
}
if (d.front().first > m)
{
d.push_back(d.front());
d.pop_front();
}
else
{
d.pop_front();
}
}
return 0;
}
problem → Problem - 450A - Codeforces