結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2017-04-24 16:27:34 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 744 bytes |
| コンパイル時間 | 494 ms |
| コンパイル使用メモリ | 21,888 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-14 07:21:40 |
| 合計ジャッジ時間 | 1,180 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘run’:
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",array+i);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
void run(void){
int n;
scanf("%d",&n);
int *array=(int *)malloc(sizeof(int)*n);
int i;
for(i=0;i<n;i++){
scanf("%d",array+i);
}
long long int max=array[0];
long long int min=array[0];
for(i=1;i<n;i++){
int t=array[i];
long long int next[8];
next[0]=max+t;
next[1]=max-t;
next[2]=max*t;
next[3]=(t==0?max:max/t);
next[4]=min+t;
next[5]=min-t;
next[6]=min*t;
next[7]=(t==0?min:min/t);
int j;
for(j=0;j<8;j++){
max=MAX(max,next[j]);
min=MIN(min,next[j]);
}
}
printf("%lld\n",max);
free(array);
return;
}
int main(void){
run();
return 0;
}
akakimidori