結果
問題 |
No.2451 Redistribute Integers
|
ユーザー |
![]() |
提出日時 | 2023-09-29 14:49:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 493 bytes |
コンパイル時間 | 1,487 ms |
コンパイル使用メモリ | 167,628 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 11:08:31 |
合計ジャッジ時間 | 4,604 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a( N ); for( int i = 0; i < N; i++ ) cin >> a[i]; long long l = -1e9 - 1, h = 1e9 + 1; while( h - l > 1 ) { long long m = (l + h) / 2; long long p = 0, np = 0; for( int i = 0; i < N; i++ ) { if( a[i] > m ) p += a[i] - m; else if( a[i] < m ) np += m - a[i]; } if( p == np ) { cout << "Yes" << endl; return 0; } if( p > np ) l = m; else h = m; } cout << "No" << endl; }