結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
![]() |
提出日時 | 2017-06-25 00:57:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 949 ms |
コンパイル使用メモリ | 91,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 04:45:24 |
合計ジャッジ時間 | 2,110 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; //全部奇数or全部偶数ならok int main(){ int N; cin >> N; ll len[N]; int ok = 0; // 1 -> odd 2 - > even FOR(i,0,N) { ll a, b; cin >> a >> b; len[i] = a + 4 * b; if(len[i] % 2 == 1 && (ok == 1 || ok == 0)) ok = 1; else if(len[i] % 2 == 0 && (ok == 2 || ok == 0)) ok = 2; else ok = -1; } if(ok == -1) { cout << -1 << endl; return 0; } sort(len, len + N); ll ans = 0; FOR(i,0,N-1) { ans += len[N-1] - len[i]; } cout << ans / 2 << endl; return 0; }