Untitled
unknown
plain_text
3 years ago
968 B
5
Indexable
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main() {
int i=0, p=0, c=0, n, foo;
cin>>n;
vector<int> a;
for (int x=1; x<=n; x++){a.push_back(x);}
vector<int> b;
for (int x=0; x<n; x++){
cin>>foo;
b.push_back(foo);
}
cout<<"--------------------------"<<endl;
for (int y : a){cout<<y<<" ";}cout<<endl;
for (int y : b){cout<<y<<" ";}cout<<endl;
while (i<a.size()){
if (b[i]==0){
c = i+1;
p += c;
cout<<p<<endl;
int j = i;
while (j+c < n){
if (b[j+c] == 0){
p += c;
cout<<p<<endl;
a.erase(a.begin()+j+c);
b[j+c] = 1;
j += c;
} else {
break;
}
}
}
i++;
}
cout << p;
}Editor is loading...