Submission #40903692


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=0;ch=getchar();}
	while('0'<=ch&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
int n,ans=0,p=0,fl=0;
char c[200010];
int main(){
	n=read();
	scanf("%s",c+1);
	for(int i=1;i<=n;i++)
		if(c[i]=='-')fl=1;
	for(int i=1;i<=n;i++)
		if(c[i]=='-')ans=max(ans,i-p-1),p=i;
	ans=max(ans,n-p);
	cout<<(fl*ans==0?-1:ans)<<'\n'; 
	return 0;
} 

Submission Info

Submission Time
Task C - Dango
User liruixuan
Language C++ (GCC 9.2.1)
Score 300
Code Size 627 Byte
Status AC
Exec Time 7 ms
Memory 3932 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%s",c+1);
      |  ~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 03_handmade_17.txt, 03_handmade_18.txt, 03_handmade_19.txt, 03_handmade_20.txt, 03_handmade_21.txt, 03_handmade_22.txt, 03_handmade_23.txt, 03_handmade_24.txt, 03_handmade_25.txt, 03_handmade_26.txt, 03_handmade_27.txt, 03_handmade_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 5 ms 3592 KiB
00_sample_01.txt AC 2 ms 3612 KiB
00_sample_02.txt AC 2 ms 3608 KiB
01_small_03.txt AC 2 ms 3568 KiB
01_small_04.txt AC 2 ms 3636 KiB
01_small_05.txt AC 1 ms 3604 KiB
01_small_06.txt AC 2 ms 3592 KiB
01_small_07.txt AC 2 ms 3404 KiB
02_random_08.txt AC 4 ms 3760 KiB
02_random_09.txt AC 5 ms 3708 KiB
02_random_10.txt AC 3 ms 3932 KiB
02_random_11.txt AC 2 ms 3644 KiB
02_random_12.txt AC 2 ms 3704 KiB
02_random_13.txt AC 2 ms 3632 KiB
02_random_14.txt AC 2 ms 3512 KiB
02_random_15.txt AC 2 ms 3704 KiB
02_random_16.txt AC 4 ms 3536 KiB
03_handmade_17.txt AC 2 ms 3692 KiB
03_handmade_18.txt AC 2 ms 3776 KiB
03_handmade_19.txt AC 2 ms 3452 KiB
03_handmade_20.txt AC 2 ms 3728 KiB
03_handmade_21.txt AC 4 ms 3708 KiB
03_handmade_22.txt AC 5 ms 3664 KiB
03_handmade_23.txt AC 4 ms 3752 KiB
03_handmade_24.txt AC 4 ms 3664 KiB
03_handmade_25.txt AC 7 ms 3616 KiB
03_handmade_26.txt AC 3 ms 3632 KiB
03_handmade_27.txt AC 2 ms 3692 KiB
03_handmade_28.txt AC 2 ms 3640 KiB