Submission #60964458


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int h[3005],dp[3005][3005];
int main(){
int n,ans=1;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&h[i]);
for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
if(h[i]==h[j]){
if(2*j>=i)
dp[i][j]=dp[j][2*j-i]+1;
else
dp[i][j]=1;
ans=max(ans,dp[i][j]+1);
}
}
}
printf("%d",ans);
return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
int h[3005],dp[3005][3005];
int main(){
	int n,ans=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&h[i]);
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(h[i]==h[j]){
				if(2*j>=i)
					dp[i][j]=dp[j][2*j-i]+1;
				else
					dp[i][j]=1;
				ans=max(ans,dp[i][j]+1);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Submission Info

Submission Time
Task C - Illuminate Buildings
User miaorunhao2
Language C++ 20 (gcc 12.2)
Score 350
Code Size 389 Byte
Status AC
Exec Time 19 ms
Memory 31188 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 scanf("%d",&h[i]);
      |                 ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 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, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 14 ms 30372 KB
random_02.txt AC 6 ms 14656 KB
random_03.txt AC 5 ms 8892 KB
random_04.txt AC 1 ms 4092 KB
random_05.txt AC 13 ms 30504 KB
random_06.txt AC 5 ms 14996 KB
random_07.txt AC 5 ms 8716 KB
random_08.txt AC 1 ms 3600 KB
random_09.txt AC 14 ms 30208 KB
random_10.txt AC 10 ms 24452 KB
random_11.txt AC 5 ms 9116 KB
random_12.txt AC 1 ms 3800 KB
random_13.txt AC 14 ms 30240 KB
random_14.txt AC 10 ms 24048 KB
random_15.txt AC 5 ms 9340 KB
random_16.txt AC 2 ms 5636 KB
random_17.txt AC 14 ms 30372 KB
random_18.txt AC 11 ms 25620 KB
random_19.txt AC 5 ms 9060 KB
random_20.txt AC 4 ms 7428 KB
random_21.txt AC 19 ms 31188 KB
random_22.txt AC 17 ms 30524 KB
random_23.txt AC 18 ms 31152 KB
random_24.txt AC 3 ms 3888 KB
random_25.txt AC 1 ms 3756 KB
sample_01.txt AC 1 ms 3704 KB
sample_02.txt AC 1 ms 3760 KB
sample_03.txt AC 1 ms 3680 KB


2025-03-31 (Mon)
01:40:48 +00:00