結果

問題 No.178 美しいWhitespace (1)
ユーザー yuppe19 😺
提出日時 2015-04-26 17:39:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 1,274 ms
コンパイル使用メモリ 159,460 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-05 02:49:56
合計ジャッジ時間 2,231 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     int n; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
main.cpp:9:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         i64 a, b; scanf("%lld%lld", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long i64;
using namespace std;

int main(void) {
    int n; scanf("%d", &n);
    vector<i64> v(n);
    for(int i=0; i<n; i++) {
        i64 a, b; scanf("%lld%lld", &a, &b);
        v[i] = a + 4 * b;
    }
    i64 hamark = *max_element(v.begin(), v.end());
    i64 res = 0;
    for(auto e : v) {
        i64 dif = hamark - e;
        if(dif & 1) { res = -1; break; }
        res += dif / 2;
    }
    printf("%lld\n", res);
    return 0;
}
0