#include "gondola.h"
#include <bits/stdc++.h>
#define inf INT_MAX
using namespace std;
int valid(int n, int arr[])
{
int ind = 0, mn = inf;
set <int> st;
for(int i = 0; i < n; i++) {
if(arr[i] < mn) ind = i, mn = arr[i];
if(st.count(arr[i])) return 0;
st.insert(arr[i]);
}
int now = mn + 1;
// cout<<ind<<" "<<now<<" ";
for(int i = (ind + 1) % n; i % n != ind; i = (i + 1) % n, now++) {
if(arr[i] <= n and arr[i] != now) {
return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int arr[], int ans[])
{
map <int, int> mp;
int mxi = 0, mx = 0;
int shift = 0;
for(int i = 0; i < n; i++) {
mp[arr[i]] = i;
if(arr[i] > mx) mxi = i, mx = arr[i];
if(arr[i] <= n) {
shift = (arr[i] - i - 1) % n;
}
}
// cout<<"what"<<"\n";
int l = mx;
for(int i = n + 1; i <= l; i++) {
int val;
if(mp.count(i)) {
val = mp[i];
}
else {
val = mxi;
}
// cout<<val<<" "<<shift<<"\n";
ans[i - (n + 1)] = (val + shift + n) % n + 1;
}
return l - n;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
436 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
11 ms |
2396 KB |
Output is correct |
7 |
Correct |
6 ms |
1240 KB |
Output is correct |
8 |
Correct |
27 ms |
4344 KB |
Output is correct |
9 |
Correct |
6 ms |
1588 KB |
Output is correct |
10 |
Correct |
24 ms |
4988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
10 ms |
2392 KB |
Output is correct |
7 |
Correct |
7 ms |
1220 KB |
Output is correct |
8 |
Correct |
25 ms |
4252 KB |
Output is correct |
9 |
Correct |
6 ms |
1632 KB |
Output is correct |
10 |
Correct |
26 ms |
4976 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
12 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
30 ms |
5456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
444 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
516 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
444 KB |
Output is correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
440 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
516 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
440 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |