Submission #32715872


Source Code Expand

#include<bits/stdc++.h>

#define int long long

using namespace std;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int MN=2e5+5;
int n,ans;
string s;
struct Node{int v,p;}a[MN];
int pre[MN],suf[MN];

signed main(void){

	cin>>n>>s;
	for(int i=1;i<=n;i++)cin>>a[i].v,a[i].p=(s[i-1]=='1');
	sort(a+1,a+n+1,[](const Node &x,const Node &y){
		return x.v<y.v;
	});
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+(a[i].p==0);
	for(int i=n;i>=1;i--)suf[i]=suf[i+1]+(a[i].p==1);
	for(int i=0;i<=n;i++)if(a[i].v!=a[i+1].v)ans=max(ans,pre[i]+suf[i+1]);
	cout<<ans<<endl;

	return 0;
}

Submission Info

Submission Time
Task C - Robot Takahashi
User YunQianMeow
Language C++ (GCC 9.2.1)
Score 300
Code Size 725 Byte
Status AC
Exec Time 89 ms
Memory 9996 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 7 ms 3564 KiB
example_01.txt AC 2 ms 3512 KiB
example_02.txt AC 2 ms 3524 KiB
hand_00.txt AC 85 ms 9928 KiB
hand_01.txt AC 84 ms 9960 KiB
hand_02.txt AC 78 ms 9956 KiB
hand_03.txt AC 89 ms 9932 KiB
hand_04.txt AC 72 ms 9944 KiB
hand_05.txt AC 2 ms 3504 KiB
hand_06.txt AC 2 ms 3592 KiB
random_00.txt AC 85 ms 9868 KiB
random_01.txt AC 85 ms 9952 KiB
random_02.txt AC 85 ms 9888 KiB
random_03.txt AC 85 ms 9928 KiB
random_04.txt AC 85 ms 9872 KiB
random_05.txt AC 86 ms 9956 KiB
random_06.txt AC 85 ms 9888 KiB
random_07.txt AC 87 ms 9884 KiB
random_08.txt AC 78 ms 9932 KiB
random_09.txt AC 77 ms 9924 KiB
random_10.txt AC 77 ms 9872 KiB
random_11.txt AC 78 ms 9996 KiB
random_12.txt AC 80 ms 9876 KiB
random_13.txt AC 77 ms 9864 KiB
random_14.txt AC 76 ms 9924 KiB
random_15.txt AC 80 ms 9888 KiB
random_16.txt AC 81 ms 9768 KiB
random_17.txt AC 81 ms 9924 KiB
random_18.txt AC 81 ms 9876 KiB
random_19.txt AC 80 ms 9948 KiB
random_20.txt AC 87 ms 9956 KiB
random_21.txt AC 85 ms 9952 KiB
random_22.txt AC 85 ms 9876 KiB
random_23.txt AC 89 ms 9956 KiB
random_24.txt AC 85 ms 9956 KiB