結果

問題 No.178 美しいWhitespace (1)
ユーザー focus
提出日時 2018-02-21 02:23:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 69,812 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 19:22:58
合計ジャッジ時間 1,425 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:21:21:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:8:35: note: 'ans' was declared here
    8 |     long long N,a,b,i,sum[1000],m,ans;
      |                                   ^~~
main.cpp:8:33: warning: 'm' may be used uninitialized [-Wmaybe-uninitialized]
    8 |     long long N,a,b,i,sum[1000],m,ans;
      |                                 ^

ソースコード

diff #

#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