Tanya and Stairways
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e4 + 10;
ll a[N];
void solve()
{
ll n,sum=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]==1) sum++;
}
cout<<sum<<endl;
for(int i=2;i<=n;i++)
if(a[i]==1) cout<<a[i-1]<<" ";
cout<<a[n]<<endl;
}
int main()
{
IOS
solve();
return 0;
}
标签:Stairways,cout,ll,ios,CF,Tanya,tie From: https://www.cnblogs.com/wsccz/p/17614787.html