码风不好请见谅,是 WA 了,不是 TLE。
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#define LL long long
#define ULL unsigned long long
#define cint const int
using namespace std;
cint INTINF=0x7f7f7f7f;
const LL LLINF=9e18;
cint N=1e6+10;
LL a[N],s[N],cnt,tot,f[N];
struct node
{
int a,b;
}ans[N];
inline auto read(){
auto x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
void write(auto x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9){
write(x/10);
}
putchar(x%10+'0');
return ;
}
int main()
{
#ifdef dbq
freopen("P6015.in","r",stdin);
freopen("P6015.out","w",stdout);
#endif
cint n=read();
for(int i=1;i<=n;i++)
{
a[i]=read();
s[i]=s[i-1]+a[i];
}
cint K=read();
int now=1;
while(1)
{
LL sum=0;
for(int i=now+1;i<=n;i++)
{
sum+=a[i];
if(sum>=s[now]) break;
}
if(sum>K||sum==s[now])
{
break;
}
if(sum<s[now])
{
f[s[now]]++;
f[K]--;
break;
}
else
{
f[s[now]]++;
f[sum]--;
}
now++;
}
queue<LL> q;
LL sum=0,cnt=0;
for(int i=1;i<=n+1;i++)
{
sum+=f[i];
if(sum>=1)
q.push(i),cnt++;
}
cout<<cnt<<endl;
while(!q.empty())
{
cout<<q.front()<<" ";
q.pop();
}
return 0;
}