Submission #758188

#TimeUsernameProblemLanguageResultExecution timeMemory
758188vjudge1Money (IZhO17_money)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 7; int arr[mxN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> arr[i]; } int ans = 0; for (int i = 0; i < n; ++i) { while (i + 1 < n) { bool ok = (arr[i] < arr[i + 1]); for (int j = 0; j < i; ++j) { if (arr[i] == arr[j] || arr[i + 1] == arr[j]) { continue; } if (arr[i] < arr[j] != arr[i + 1] < arr[j] || arr[i] > arr[j] != arr[i + 1] > arr[j]) { ok = false; } } if (!ok) { break; } ++i; } ++ans; } cout << ans << "\n"; }

Compilation message (stderr)

money.cpp: In function 'int32_t main()':
money.cpp:27:28: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
   27 |                 if (arr[i] < arr[j] != arr[i + 1] < arr[j] ||
      |                     ~~~~~~~^~~~~~~~
money.cpp:28:32: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
   28 |                         arr[i] > arr[j] != arr[i + 1] > arr[j]) {
      |                         ~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...