QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#259564 | #7695. Double Up | billytngo | RE | 94ms | 42700kb | Java8 | 1.4kb | 2023-11-21 01:40:05 | 2023-11-21 01:40:06 |
Judging History
answer
import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Set;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
public class Main {
private static Scanner sc;
private static final int INF = 1000000000;
private static int getK(int v) {
// TODO Auto-generated method stub
int ret = 0;
while(v > 1) {
ret++;
v/=2;
}
return ret;
}
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
sc = new Scanner(System.in);
int n = sc.nextInt();
List<Integer> P = new ArrayList<Integer>();
for(int i=0;i<n;i++) {
int v = getK(sc.nextInt());
P.add(v);
}
while(P.size()>1) {
List<Integer> _P = new ArrayList<Integer>();
int m = INF;
for(int i=0;i<P.size();i++) {
m = Math.min(m, P.get(i));
}
for(int i=0;i<P.size();i++) {
if(i+1<P.size() && P.get(i).equals(m) && P.get(i+1).equals(m)) {
_P.add(P.get(i)+1);
i++;
continue;
}
if(P.get(i).equals(m)) {
continue;
}
_P.add(P.get(i));
}
P = _P;
}
BigInteger ret = new BigInteger("1");
for(int i=0;i<P.get(0);i++) {
ret = ret.multiply(new BigInteger("2"));
}
System.out.println(ret);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 50ms
memory: 38392kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: 0
Accepted
time: 94ms
memory: 42700kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
512
result:
ok single line: '512'
Test #3:
score: -100
Runtime Error
input:
1000 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...