Submission #55064313


Source Code Expand

Copy
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
int t;
cin >> t;
string s;
cin >> s;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].first;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int t;
	cin >> t;
	string s;
	cin >> s;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first;
		a[i].second = s[i] - '0';
	}
	sort(a.begin(), a.end());
	vector<int> cnt0(n + 1);
	long long ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		cnt0[i] = cnt0[i + 1];
		if (a[i].second == 0) {
			cnt0[i]++;
		} else {
			int index = upper_bound(a.begin(), a.end(), make_pair(a[i].first + 2 * t, 0ll)) - a.begin();
			ans += cnt0[i] - cnt0[index];
		}
	}
	cout << ans << '\n';
}

Submission Info

Submission Time
Task D - Ghost Ants
User N00BGH0ST
Language C++ 20 (gcc 12.2)
Score 350
Code Size 851 Byte
Status AC
Exec Time 35 ms
Memory 8360 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3376 KB
00_sample_01.txt AC 1 ms 3440 KB
01_random_00.txt AC 34 ms 8264 KB
01_random_01.txt AC 21 ms 6280 KB
01_random_02.txt AC 35 ms 8276 KB
01_random_03.txt AC 27 ms 7288 KB
01_random_04.txt AC 34 ms 8148 KB
01_random_05.txt AC 17 ms 5764 KB
01_random_06.txt AC 34 ms 8244 KB
01_random_07.txt AC 26 ms 6792 KB
01_random_08.txt AC 32 ms 8264 KB
01_random_09.txt AC 30 ms 7484 KB
01_random_10.txt AC 35 ms 8296 KB
01_random_11.txt AC 31 ms 7740 KB
01_random_12.txt AC 35 ms 8144 KB
01_random_13.txt AC 26 ms 6604 KB
01_random_14.txt AC 33 ms 8216 KB
01_random_15.txt AC 17 ms 5776 KB
01_random_16.txt AC 33 ms 8144 KB
01_random_17.txt AC 25 ms 6900 KB
01_random_18.txt AC 34 ms 8240 KB
01_random_19.txt AC 28 ms 7468 KB
01_random_20.txt AC 19 ms 8300 KB
01_random_21.txt AC 20 ms 8216 KB
01_random_22.txt AC 22 ms 8272 KB
01_random_23.txt AC 22 ms 8360 KB
01_random_24.txt AC 23 ms 8108 KB
01_random_25.txt AC 22 ms 8200 KB


2025-02-27 (Thu)
22:27:29 +00:00