Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <ctype.h>
- #include <string.h>
- typedef long long LL;
- typedef unsigned long long ULL;
- LL a[10020] = {0};
- #define MAX(a,b) (((a)>(b))?(a):(b))
- #define MIN(a,b) (((a)<(b))?(a):(b))
- int main(){
- int n,i,j,c,d;
- while(~scanf("%d",&n)){
- c = 0;d = n;
- for(i = 0;i < n;i++){
- scanf("%lld",a + i);
- }
- LL m = 9223372036854775807,M = -1;
- for(i = 0;i < n;i++){
- for(j = i + 1;j < n;j++){
- if(a[j] - a[i] > M){
- c = i;d = j;
- M = a[j] - a[i];
- }
- }
- }
- if(M > 0){
- printf("%lld %d %d\n",M,c + 1,d + 1);
- }
- else{
- puts("No profit!");
- }
- memset(a,0,sizeof(a));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement