PTQMSEQ - Dãy số vòng tròn

Tác giả: hieult

Ngôn ngữ: C++

#include<cstdio>
#define oo 111111111
//#include<conio.h>


long long Min,Max,tong = 0,kq1 = -oo,kq2 = oo,x;
int n;

int main(){
     //freopen("PTQMSEQ.in","r",stdin); 
     bool check = false;
     scanf("%d",&n);
     scanf("%lld",&x);
     tong+=x;
     if(x>0) check = true;
     kq1 >?= tong;
     kq2 <?= tong;
     Min = x;
     Max = x;
     for(int i = 2;i<=n;i++)
     {
           scanf("%lld",&x);  
           if(x>0) check = true;
           tong+=x;
           kq1 >?= tong-Min;
           kq2 <?= tong-Max;
           Min <?= tong;
           Max >?= tong;
     }
     if(!check)
     printf("%lld\n",kq1);
     else{
     //printf("%lld %lld\n",kq1,kq2);
     kq1 >?= (tong-kq2);
     printf("%lld",kq1);
     }
    // getch();
}

Download