結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-06 22:37:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 596 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 22,528 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 22:58:56 |
| 合計ジャッジ時間 | 644 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d",&N); //N 個の正整数
| ~~~~~^~~~~~~~~
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d",&X,&Y); //2 つ組(X,Y)
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main()
{
int i = 0; //カウンタ用
int a = 0; //値の保管用
int N; // N個の整数
int X; // Xの値
int Y; // Yの値
scanf("%d",&N); //N 個の正整数
for(i=0;i<N;i++)
{
scanf("%d %d",&X,&Y); //2 つ組(X,Y)
//□ +Xk=Ykを求める式
Y-=X;
//存在しない条件
if(Y <= 0)
{
printf("-1");
return 0;
}
if(a == 0)
{
a = Y;
}
//正整数じゃない条件
else if(a!=Y)
{
printf("-1");
return 0;
}
}
printf("%d",a);
return 0;
}