B. Xenia and Ringroad(这个大水题。。。。)
不想多说了,,,,心痛,,,
1 #include<stdio.h> 2 3 int a[100010]; 4 int main () 5 { 6 int m,n,i,j; 7 while(scanf("%d%d",&n,&m)!=EOF) 8 { 9 __int64 sum=0; 10 a[0]=1; 11 for(i=1;i<=m;i++) 12 { 13 scanf("%d",&a[i]); 14 if(a[i]>=a[i-1]){sum+=a[i]-a[i-1];} 15 if(a[i]<a[i-1]){sum+=(n-a[i-1])+a[i];} 16 } 17 printf("%I64d\n",sum); 18 } 19 }