Advertisement
wojiaocbj

R

Jun 9th, 2022
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. typedef long long LL;
  7. typedef unsigned long long ULL;
  8. LL a[10020] = {0};
  9. #define MAX(a,b) (((a)>(b))?(a):(b))
  10. #define MIN(a,b) (((a)<(b))?(a):(b))
  11. int main(){
  12.     int n,i,j,c,d;
  13.  
  14.     while(~scanf("%d",&n)){
  15.         c = 0;d = n;
  16.         for(i = 0;i < n;i++){
  17.             scanf("%lld",a + i);
  18.         }
  19.         LL m = 9223372036854775807,M = -1;
  20.         for(i = 0;i < n;i++){
  21.             for(j = i + 1;j < n;j++){
  22.                 if(a[j] - a[i] > M){
  23.                     c = i;d = j;
  24.                     M = a[j] - a[i];
  25.                 }
  26.             }
  27.         }
  28.         if(M > 0){
  29.             printf("%lld %d %d\n",M,c + 1,d + 1);
  30.         }
  31.         else{
  32.             puts("No profit!");
  33.         }
  34.  
  35.         memset(a,0,sizeof(a));
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement