Submission #813488

# Submission time Handle Problem Language Result Execution time Memory
813488 2023-08-07T18:49:37 Z EntityPlantt Exam (eJOI20_exam) C++14
0 / 100
2 ms 852 KB
#include <iostream>
using namespace std;
int n, a[10000], b[10000], i, j, v, r;
bool bo;
int main() {
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", a + i);
    scanf("%d", b); v = *b;
    for (i = 1; i < n; i++) {
        scanf("%d", b + i);
        if (v != b[i]) v = 0;
    }
    if (v) {
        fprintf(stderr, "Two pointers\n");
        for (i = 0, j = -1; i < n; i++) {
            if (a[i] > v) {
                if (bo) r += i - j - 1;
                bo = false; j = i;
            }
            else if (a[i] == v) bo = true;
        }
        if (bo) r += n - j - 1;
        printf("%d", r);
        return 0;
    }
    if (n > 5000) {
        // Segment tree
        return 0;
    }
    // DP
    return 0;
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
exam.cpp:7:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     for (i = 0; i < n; i++) scanf("%d", a + i);
      |                             ~~~~~^~~~~~~~~~~~~
exam.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d", b); v = *b;
      |     ~~~~~^~~~~~~~~
exam.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d", b + i);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 2 ms 852 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -