Submission #758188

# Submission time Handle Problem Language Result Execution time Memory
758188 2023-06-14T08:52:26 Z vjudge1 Money (IZhO17_money) C++17
0 / 100
1 ms 332 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 328 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 328 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 328 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 328 KB Output isn't correct
8 Halted 0 ms 0 KB -