Submission

Status:
-P-PPP----

Score: 40

User: KhunKK9722

Problemset: ไฟส่อง

Language: cpp

Time: 0.001 second

Submitted On: 2025-03-10 09:54:56

#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+=359;
        for(int x = tmp1-1; x < tmp2; x++){
            if(x>=360) a[x-360]=1;
            else a[x]=1;
        }
    }
    int tmp = 0;
    int tmpi;
    int maxtmpi=0;
    for(int i = 0; i < 360; i++){
        tmpi = i+1;
        
        // if(i+1>360) tmpi = i;
        // else tmpi = i+1;
        if(a[i]==1&&a[tmpi]==1) {tmp++;if(tmpi>maxtmpi) maxtmpi=tmpi;}
        else if (a[i]==1) {if(tmp > ans) ans = tmp;}
        else {tmp=0;}
    }
    if(maxtmpi>=359) ans++;
    printf("%d",ans);
}