Submission #72893261
Source Code Expand
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().D();
}
public void A() {
Scanner in = new Scanner(System.in);
String s = in.next();
System.out.println(s+"s");
}
public void B() {
Scanner in = new Scanner(System.in);
long N = in.nextInt();
long K = in.nextInt();
long sum=0;
int year=0;
while ( true ) {
sum+=N;
if ( sum>=K ) break;
N++;
year++;
}
System.out.println(year);
}
public void C() {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
long T = in.nextLong();
long[] A = new long[N];
for (int i=0;i<N;i++) A[i] = in.nextLong();
long prev=0;
boolean open = false;
int idx = 0;
long score = 0;
for (long t=0;t<T;t++) {
if ( t==0 ) open=true;
if ( idx < N && A[idx]==t ) {
idx++;
if (open) { open=false;prev=0;}
}
if ( !open && prev==100 ) {open=true;prev=0;}
prev++;
if ( open ) score++;
}
System.out.println(score);
}
public void D() {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
for (int i=0;i<T;i++) {
int N = in.nextInt();
Pos[] R = new Pos[N];
Pos[] P = new Pos[N];
for (int j=0;j<N;j++) {
int y = in.nextInt();
R[j] = new Pos(j,y);
P[j] = R[j];
}
// System.err.println("turn="+i);
// for ( Pos p : R ) System.err.print(p.toString() + " ");
// System.err.println("");
long step = 0;
int idx=0;
while (idx<N) {
Arrays.sort(P);
// for ( Pos p : R ) System.err.print(p.toString() + " ");
// System.err.println("");
//左を捜査
int x = P[idx].x;
idx++;
if ( x>0 ) {
int x2=x-1;
int d = R[x2].y-R[x].y;
if ( d>1 ) {
R[x2].y -=(d-1);
step += (d-1);
}
}
if ( x<N-1 ) {
int x2=x+1;
int d = R[x2].y-R[x].y;
if ( d>1 ) {
R[x2].y -=(d-1);
step += (d-1);
}
}
}
System.out.println(step);
}
}
}
class Pos implements Comparable<Pos> {
public Pos(int j, int i) {
this.x = j;
this.y = i;
}
int x,y;
public String toString() {
return x + "," + y;
}
@Override
public int compareTo( Pos p ){
if ( this.y == p.y ) {
return this.x - p.x;
} else {
return this.y - p.y;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Pawn Line |
| User | yellowsubmarine |
| Language | Java24 (OpenJDK 24.0.2) |
| Score | 0 |
| Code Size | 2450 Byte |
| Status | TLE |
| Exec Time | > 2000 ms |
| Memory | 72196 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt |
| All | killer_01.txt, killer_02.txt, killer_03.txt, killer_04.txt, killer_05.txt, killer_06.txt, sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| killer_01.txt | TLE | > 2000 ms | 57528 KiB |
| killer_02.txt | TLE | > 2000 ms | 57516 KiB |
| killer_03.txt | TLE | > 2000 ms | 57668 KiB |
| killer_04.txt | TLE | > 2000 ms | 57536 KiB |
| killer_05.txt | TLE | > 2000 ms | 57524 KiB |
| killer_06.txt | TLE | > 2000 ms | 57556 KiB |
| sample_01.txt | AC | 73 ms | 40132 KiB |
| test_01.txt | AC | 385 ms | 65464 KiB |
| test_02.txt | AC | 484 ms | 65100 KiB |
| test_03.txt | AC | 531 ms | 65448 KiB |
| test_04.txt | AC | 533 ms | 67972 KiB |
| test_05.txt | AC | 601 ms | 68112 KiB |
| test_06.txt | AC | 585 ms | 68260 KiB |
| test_07.txt | AC | 589 ms | 67872 KiB |
| test_08.txt | AC | 582 ms | 68040 KiB |
| test_09.txt | AC | 583 ms | 67712 KiB |
| test_10.txt | AC | 622 ms | 67976 KiB |
| test_11.txt | AC | 583 ms | 67884 KiB |
| test_12.txt | AC | 1110 ms | 72196 KiB |
| test_13.txt | AC | 1005 ms | 63392 KiB |
| test_14.txt | TLE | > 2000 ms | 47228 KiB |
| test_15.txt | TLE | > 2000 ms | 47412 KiB |
| test_16.txt | TLE | > 2000 ms | 41100 KiB |
| test_17.txt | TLE | > 2000 ms | 40740 KiB |
| test_18.txt | TLE | > 2000 ms | 41124 KiB |
| test_19.txt | TLE | > 2000 ms | 41412 KiB |
| test_20.txt | TLE | > 2000 ms | 56752 KiB |
| test_21.txt | TLE | > 2000 ms | 56900 KiB |
| test_22.txt | TLE | > 2000 ms | 56904 KiB |
| test_23.txt | TLE | > 2000 ms | 57040 KiB |
| test_24.txt | TLE | > 2000 ms | 57172 KiB |
| test_25.txt | TLE | > 2000 ms | 56896 KiB |
| test_26.txt | TLE | > 2000 ms | 56864 KiB |
| test_27.txt | TLE | > 2000 ms | 56660 KiB |
| test_28.txt | TLE | > 2000 ms | 56840 KiB |
| test_29.txt | TLE | > 2000 ms | 57048 KiB |
| test_30.txt | TLE | > 2000 ms | 53144 KiB |
| test_31.txt | TLE | > 2000 ms | 50248 KiB |
| test_32.txt | TLE | > 2000 ms | 56652 KiB |
| test_33.txt | TLE | > 2000 ms | 52628 KiB |
| test_34.txt | TLE | > 2000 ms | 56028 KiB |
| test_35.txt | TLE | > 2000 ms | 40984 KiB |
| test_36.txt | TLE | > 2000 ms | 51284 KiB |
| test_37.txt | TLE | > 2000 ms | 48728 KiB |
| test_38.txt | TLE | > 2000 ms | 56364 KiB |
| test_39.txt | TLE | > 2000 ms | 53660 KiB |
| test_40.txt | TLE | > 2000 ms | 56764 KiB |
| test_41.txt | TLE | > 2000 ms | 57324 KiB |
| test_42.txt | TLE | > 2000 ms | 57656 KiB |
| test_43.txt | TLE | > 2000 ms | 57436 KiB |
| test_44.txt | TLE | > 2000 ms | 57488 KiB |
| test_45.txt | TLE | > 2000 ms | 57092 KiB |
| test_46.txt | TLE | > 2000 ms | 57044 KiB |
| test_47.txt | TLE | > 2000 ms | 57080 KiB |
| test_48.txt | TLE | > 2000 ms | 56936 KiB |
| test_49.txt | TLE | > 2000 ms | 57108 KiB |
| test_50.txt | TLE | > 2000 ms | 57060 KiB |
| test_51.txt | TLE | > 2000 ms | 57160 KiB |
| test_52.txt | TLE | > 2000 ms | 57168 KiB |
| test_53.txt | TLE | > 2000 ms | 57304 KiB |
| test_54.txt | TLE | > 2000 ms | 56976 KiB |
| test_55.txt | TLE | > 2000 ms | 57132 KiB |
| test_56.txt | TLE | > 2000 ms | 56784 KiB |
| test_57.txt | TLE | > 2000 ms | 57060 KiB |
| test_58.txt | TLE | > 2000 ms | 56980 KiB |
| test_59.txt | TLE | > 2000 ms | 56572 KiB |
| test_60.txt | TLE | > 2000 ms | 57028 KiB |
| test_61.txt | TLE | > 2000 ms | 57036 KiB |
| test_62.txt | TLE | > 2000 ms | 57056 KiB |
| test_63.txt | TLE | > 2000 ms | 56852 KiB |
| test_64.txt | TLE | > 2000 ms | 56936 KiB |
| test_65.txt | TLE | > 2000 ms | 56992 KiB |