Submission
Status:
-P-PP--P--
Score: 40
User: KhunKK9722
Problemset: ไฟส่อง
Language: cpp
Time: 0.001 second
Submitted On: 2025-03-10 09:44:21
#include <stdio.h>
int n;
int a[360]={};
int tmp1,tmp2;
int ans=0;
int main(){
scanf("%d",&n);
for(int i = 0; i < n; i++){
scanf("%d %d",&tmp1,&tmp2);
if(tmp2<tmp1) tmp2+=360;
for(int x = tmp1-1; x < tmp2; x++){
if(x>=360) a[x-360]=1;
else a[x]=1;
}
}
int tmp = 0;
int tmpi;
for(int i = 0; i < 360; i++){
if(i+1>=360) tmpi = i-359;
else tmpi = i+1;
if(a[i]==1&&a[tmpi]==1) {tmp++;}
else if (a[i]==1) {if(tmp > ans) ans = tmp;}
else {tmp=0;}
}
printf("%d",ans);
}