Submission #849844

# Submission time Handle Problem Language Result Execution time Memory
849844 2023-09-15T12:40:14 Z nnin Gap (APIO16_gap) C++14
30 / 100
2000 ms 3060 KB
#include "gap.h"
#define ll long long
#include<bits/stdc++.h>
using namespace std;

long long findGap(int T, int N) {
    ll mn, mx, curmn, curmx;
    MinMax((ll)0, (ll)1e18, &mn, &mx);
    ll ans = 0;
    if(T==1) {
        while(N>2) {
            MinMax(mn+1, mx-1, &curmn, &curmx);
            ans = max(ans,  max(curmn-mn, mx-curmx));
            N -= 2;
            mx = curmx;
            mn = curmn;
        }
        ans = max(ans, mx-mn);
    } else {
        int gap = ans = (mx-mn)/(N-1);
        int cur = 0;
        for(mn;mn<=mx;mn+=gap) {
            MinMax(mn+1, mn+gap, &curmn, &curmx);
            if(curmn==-1) {
                cur += gap;
            } else {
                ans = max(ans, cur+curmn-mn);
                cur = mn+gap-curmx;
            }
        }
    }
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:22:13: warning: statement has no effect [-Wunused-value]
   22 |         for(mn;mn<=mx;mn+=gap) {
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2492 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2460 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 7 ms 2584 KB Output is correct
17 Correct 8 ms 2588 KB Output is correct
18 Correct 8 ms 2588 KB Output is correct
19 Correct 8 ms 2588 KB Output is correct
20 Correct 6 ms 2564 KB Output is correct
21 Correct 30 ms 2852 KB Output is correct
22 Correct 29 ms 2856 KB Output is correct
23 Correct 30 ms 2852 KB Output is correct
24 Correct 30 ms 2856 KB Output is correct
25 Correct 26 ms 2844 KB Output is correct
26 Correct 30 ms 2852 KB Output is correct
27 Correct 30 ms 2856 KB Output is correct
28 Correct 33 ms 2852 KB Output is correct
29 Correct 30 ms 2680 KB Output is correct
30 Correct 24 ms 2848 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 2392 KB Time limit exceeded
2 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
4 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
5 Correct 0 ms 2392 KB Output is correct
6 Execution timed out 3057 ms 2392 KB Time limit exceeded
7 Execution timed out 3061 ms 2388 KB Time limit exceeded
8 Execution timed out 3027 ms 2392 KB Time limit exceeded
9 Execution timed out 3099 ms 2392 KB Time limit exceeded
10 Correct 1 ms 2392 KB Output is correct
11 Execution timed out 3042 ms 2392 KB Time limit exceeded
12 Execution timed out 3049 ms 2388 KB Time limit exceeded
13 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
14 Execution timed out 3056 ms 2392 KB Time limit exceeded
15 Correct 1 ms 2392 KB Output is correct
16 Execution timed out 3056 ms 2580 KB Time limit exceeded
17 Runtime error 4 ms 2580 KB Execution failed because the return code was nonzero
18 Execution timed out 3078 ms 2752 KB Time limit exceeded
19 Execution timed out 3023 ms 2580 KB Time limit exceeded
20 Partially correct 6 ms 2568 KB Partially correct
21 Execution timed out 3019 ms 2860 KB Time limit exceeded
22 Execution timed out 3040 ms 2644 KB Time limit exceeded
23 Execution timed out 3042 ms 2860 KB Time limit exceeded
24 Execution timed out 3015 ms 2856 KB Time limit exceeded
25 Correct 39 ms 2856 KB Output is correct
26 Execution timed out 3051 ms 3060 KB Time limit exceeded
27 Execution timed out 3015 ms 2852 KB Time limit exceeded
28 Execution timed out 3082 ms 2860 KB Time limit exceeded
29 Execution timed out 3020 ms 2852 KB Time limit exceeded
30 Partially correct 29 ms 2828 KB Partially correct
31 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero