Submission #412901

# Submission time Handle Problem Language Result Execution time Memory
412901 2021-05-27T18:52:25 Z aris12345678 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
3 ms 308 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1e3+5;
int a[mxN];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++)
        scanf("%d", &a[i]);
    int ans = 0;
    for(int i = 0; i < m; i++) {
        int mx = 0, mn = INT_MAX;
        for(int j = i; j < m; j++) {
            mx = max(mx, a[j]);
            mn = min(mn, a[j]);
            ans = max(ans, mx-mn-(j-i+1));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
maxcomp.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -