ABC360 D
  • 板块学术版
  • 楼主Dtw_
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/6/30 21:49
  • 上次更新2024/7/1 09:48:26
查看原帖
ABC360 D
938933
Dtw_楼主2024/6/30 21:49
#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

#define TRACE 1
#define tcout TRACE && cout

#define IN(o) insert(o)

#define fi first
#define se second

#define int long long

#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int INF = 0x3f3f3f3f3f3f3f3f;

const int P = 998244353;

const int N = 1e6 + 10;

int n, t;

char s[N];

inline int llceil(int a)
{
	if(a % 2)
	{
		return a / 2 + 1;
	}
	return a / 2;
}

queue<int> b;

signed main()
{
	cin >> n >> t;
	for(int i=1; i<=n; i++) cin >> s[i];
	int res = 0;
	for(int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		if(s[i] == '0')
		{
			while(!b.empty())
			{
				int y = (x - b.front());
				if(llceil(y) <= t)
				{
					res += b.size();
					cout << b.size() << " ";
					break;
				}
				else b.pop();
			}
		}
		if(s[i] == '1') b.push(x);
	}
	cout << res;
	return 0;
}


/*
3 1
100
1 2 3
*/

2024/6/30 21:49
加载中...