59 lines
1.0 KiB
Java
59 lines
1.0 KiB
Java
package chelper;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import io.InputReader;
|
|
import io.OutputWriter;
|
|
import misc.SimpleSavingChelperSolution;
|
|
|
|
|
|
public class C extends SimpleSavingChelperSolution {
|
|
|
|
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
|
wrapSolve(testNumber, in, out);
|
|
}
|
|
|
|
@Override
|
|
public void solve(int testNumber) {
|
|
int n = in.nextInt();
|
|
long k = in.nextLong();
|
|
|
|
long left = k;
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
long current = -1;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
if (current + 1 <= left) {
|
|
current++;
|
|
left -= current;
|
|
sb.append('(');
|
|
|
|
continue;
|
|
}
|
|
|
|
while (current + 1 > left) {
|
|
sb.append(')');
|
|
current--;
|
|
}
|
|
|
|
current++;
|
|
left -= current;
|
|
sb.append('(');
|
|
}
|
|
|
|
while (current + 1 > 0) {
|
|
sb.append(')');
|
|
current--;
|
|
}
|
|
|
|
if (left > 0) {
|
|
out.println("Impossible");
|
|
return;
|
|
}
|
|
|
|
out.println(sb.toString());
|
|
}
|
|
}
|