Submission #1093768

#TimeUsernameProblemLanguageResultExecution timeMemory
1093768ramzialoulouNizin (COCI16_nizin)C++17
0 / 100
35 ms6244 KiB
#include <bits/stdc++.h> using namespace std; #ifdef Ramzi #include "debug.h" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 0 << "\n"; return 0; } if (n == 2) { cout << (a[0] == a[1] ? 0 : 1) << "\n"; return 0; } int l = 0, r = n - 1; int ans = 0; while (l < r) { if (a[l] != a[r]) { ++ans; if (a[l] + a[l + 1] == a[r]) { ++l; } else if (a[r] + a[r - 1] == a[l]){ --r; } else { ++ans; ++l, --r; } } ++l, --r; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...