結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー focus
提出日時 2018-02-21 02:23:56
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 510 ms
コンパイル使用メモリ 83,968 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 07:17:17
合計ジャッジ時間 1,261 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:53,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]',
    inlined from 'int main()' at main.cpp:14:16:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:263:7: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
  263 |       if (__a < __b)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:8:33: note: 'm' was declared here
    8 |     long long N,a,b,i,sum[1000],m,ans;
      |                                 ^
main.cpp:17:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   17 |         ans += (m-sum[i]);
      |         ~~~~^~~~~~~~~~~~~
main.cpp:8:35: note: 'ans' was declared here
    8 |     long long N,a,b,i,sum[1000],m,ans;
      |                                   ^~~

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main(){
    long long N,a,b,i,sum[1000],m,ans;
    bool flag = false;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> a >> b;
        sum[i] = a + b*4;
        m = max(m,sum[i]);
    }
    for(i=0;i<N;i++){
        ans += (m-sum[i]);
        if((m-sum[i])%2==0) flag = true;
    }
    if(flag)    cout << ans/2;
    else    cout << ans;
    return 0;
}
0