#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1005];
void Init(int N) {
n=N;
for(int i=1;i<=n;i++) a[i]=0;
}
int MakeTurn(int M) {
a[M]=1;
int l=-999999,r=-999999;
for(int i=M+1;i<=n;i++){
if(!a[i]){
r=i;
break;
}
}
for(int i=M-1;i;i--){
if(!a[i]){
l=i;
break;
}
}
if(l==-999999) return r;
if(r==-999999) return l;
int res=(r-M>M-l?l:r);
a[res]=1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2036 KB |
Output is correct |
2 |
Correct |
0 ms |
2036 KB |
Output is correct |
3 |
Correct |
0 ms |
2036 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2036 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |