結果
問題 | No.185 和風 |
ユーザー |
![]() |
提出日時 | 2015-04-20 00:11:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 688 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 65,656 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 19:04:01 |
合計ジャッジ時間 | 1,189 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 10 ms
5,376 KB |
testcase_02 | AC | 9 ms
5,376 KB |
testcase_03 | AC | 5 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { vector<long long>p; int n; cin >> n; for (int i = 0; i < n; i++){ int x, y; cin >> x >> y; if (n == 1&&y-x>=0){ cout << y - x << endl; return 0; } for (int i = 0; i < 10000&&x+i<=y; i++){ if (x + i == y){ p.push_back(i); } } } sort(p.begin(), p.end()); bool flag = false; for (int i = 0; i < p.size()-1&&p.size()>1; i++){ if (p[i] == p[i + 1]){ int c=0; for (int i2 = i+1; i2 < i + n; i2++){ if (p[i] == p[i2]){ c++; } } if (c == n - 1){ cout << p[i] << endl; flag = true; } } } if (!flag){ cout << "-1" << endl; } }