結果
問題 | No.1120 Strange Teacher |
ユーザー | kawara_y_kyopro |
提出日時 | 2020-07-22 22:15:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,473 bytes |
コンパイル時間 | 984 ms |
コンパイル使用メモリ | 107,452 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 18:39:42 |
合計ジャッジ時間 | 2,389 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 22 ms
6,944 KB |
testcase_11 | AC | 22 ms
6,944 KB |
testcase_12 | AC | 22 ms
6,944 KB |
testcase_13 | AC | 22 ms
6,940 KB |
testcase_14 | AC | 22 ms
6,944 KB |
testcase_15 | AC | 22 ms
6,944 KB |
testcase_16 | AC | 21 ms
6,944 KB |
testcase_17 | AC | 21 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 23 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:88:39: warning: 'diff' may be used uninitialized [-Wmaybe-uninitialized] 88 | else cout << diff + ab << '\n'; | ^~~~ main.cpp:51:23: note: 'diff' was declared here 51 | int bcnt = 0, diff; | ^~~~
ソースコード
#include <iostream> #include <array> #include <algorithm> #include <vector> #include <bitset> #include <set> #include <unordered_set> #include <cmath> #include <complex> #include <deque> #include <iterator> #include <numeric> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <string> #include <tuple> #include <utility> #include <limits> #include <iomanip> #include <functional> #include <cassert> using namespace std; using ll=long long; template<class T> using V = vector<T>; template<class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i) #define REP(i, n) rep(i, 0, n) #define ALL(v) v.begin(),v.end() template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; } template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; } #define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' '); const long long MOD = 1000000007; const long long HIGHINF = (long long)1e18; const int INF = (int)1e9; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; V<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; if (a == b) cout << 0 << '\n'; else { int bcnt = 0, diff; for (int i = 0; i < n; i++) { if (a[i] < b[i]) { bcnt++; diff = b[i] - a[i]; } } if (bcnt > 1) { cout << -1 << '\n'; return 0; } for (int i = 0; i < n; i++) { if (a[i] < b[i]) a[i] = b[i]; else a[i] -= diff; } bcnt = 0; for (int i = 0; i < n; i++) { if (a[i] == b[i]) bcnt++; } if (bcnt == n) { cout << diff << '\n'; return 0; } else if (bcnt != 2) { cout << -1 << '\n'; return 0; } else { int ab = INF; for (int i = 0; i < n; i++) { if (a[i] == b[i]) continue; if (ab == INF) ab = a[i] - b[i]; else if (ab != a[i] - b[i]) { cout << -1 << '\n'; return 0; } } if (ab < 0 || (ab & 1)) cout << -1 << '\n'; else cout << diff + ab << '\n'; } } return 0; }