编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#24119 #2025. 整理书籍 Accepted 100 2055 ms 12208 K Java / 930 B 192022212694 2024-12-21 13:49:34
显示原始代码
import java.io.*;
import java.util.*;
public class Main {
    static Read sc = new Read();
    static int n, res;
    static int[] arr;
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int b = 0;
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1 - i; j++) {
                if (arr[j + 1] < arr[j]) {
                    b = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = b;
                    res++;
                }
            }
        }
        out.print(res);
        out.close();
    }
}
class Read {
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    public int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    public String next() throws Exception {
        in.nextToken();
        return in.sval;
    }
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:83 ms
内存:10464 KiB

输入文件(test1.in

4
1 2 3 4

答案文件(test1.out

0

用户输出

0

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:82 ms
内存:10464 KiB

输入文件(test2.in

3
3 2 1 

答案文件(test2.out

3

用户输出

3

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:84 ms
内存:10404 KiB

输入文件(test3.in

5
1 3 2 8 2

答案文件(test3.out

3

用户输出

3

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:83 ms
内存:10556 KiB

输入文件(test4.in

5
6 6 6 6 6

答案文件(test4.out

0

用户输出

0

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:94 ms
内存:11244 KiB

输入文件(test5.in

319
506566789 327144372 89894848 82307491 63689091 775175452 96835980 649944758 902552411 438220354
<3050 bytes omitted>

答案文件(test5.out

25278

用户输出

25278

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:110 ms
内存:12032 KiB

输入文件(test6.in

947
815575750 910768051 218201641 216996443 204697698 136585682 518745137 983803138 360270231 59030
<9278 bytes omitted>

答案文件(test6.out

217374

用户输出

217374

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:107 ms
内存:12208 KiB

输入文件(test7.in

796
191775954 644327900 78214263 716137367 996514479 31160736 304150983 823649428 308342819 2563026
<7774 bytes omitted>

答案文件(test7.out

156551

用户输出

156551

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:115 ms
内存:11912 KiB

输入文件(test8.in

1881
235713105 951318308 291866049 995629709 412494889 589031090 39093732 615015002 426154600 75849
<18491 bytes omitted>

答案文件(test8.out

892955

用户输出

892955

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:112 ms
内存:12008 KiB

输入文件(test9.in

1348
971656466 936991836 830049406 40043157 373066467 602263839 173973571 913458976 832436993 71298
<13220 bytes omitted>

答案文件(test9.out

462777

用户输出

462777

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:111 ms
内存:12076 KiB

输入文件(test10.in

1037
150644678 587802059 504985530 340639568 112692885 258363760 110892482 817447798 254134275 4932
<10149 bytes omitted>

答案文件(test10.out

256584

用户输出

256584

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:117 ms
内存:11908 KiB

输入文件(test11.in

1654
660101481 273261451 985223938 316971770 262889743 216837385 325436346 808941735 948716368 9026
<16276 bytes omitted>

答案文件(test11.out

676912

用户输出

676912

系统信息

Exited with return code 0
测试点 #12
Accepted
得分:100
用时:98 ms
内存:11256 KiB

输入文件(test12.in

441
843725536 59056084 802812355 948564120 727280090 88156977 229269063 224656623 128608409 8940626
<4258 bytes omitted>

答案文件(test12.out

48977

用户输出

48977

系统信息

Exited with return code 0
测试点 #13
Accepted
得分:100
用时:98 ms
内存:11352 KiB

输入文件(test13.in

463
351189978 485474969 894607950 946993395 47613651 680165310 982698434 898162241 892955070 393852
<4499 bytes omitted>

答案文件(test13.out

53508

用户输出

53508

系统信息

Exited with return code 0
测试点 #14
Accepted
得分:100
用时:115 ms
内存:12028 KiB

输入文件(test14.in

1951
137861771 412536014 143522023 863574995 362912702 553837620 453349856 756903737 315321078 5191
<19211 bytes omitted>

答案文件(test14.out

939252

用户输出

939252

系统信息

Exited with return code 0
测试点 #15
Accepted
得分:100
用时:111 ms
内存:12104 KiB

输入文件(test15.in

1148
62969127 845596993 650410567 172165143 205789280 384864211 68033397 73329829 530110424 5400378
<11247 bytes omitted>

答案文件(test15.out

322812

用户输出

322812

系统信息

Exited with return code 0
测试点 #16
Accepted
得分:100
用时:111 ms
内存:12064 KiB

输入文件(test16.in

1133
424466629 746613070 168655216 626669543 993891318 238748425 184809223 142125785 904096008 5420
<11115 bytes omitted>

答案文件(test16.out

321133

用户输出

321133

系统信息

Exited with return code 0
测试点 #17
Accepted
得分:100
用时:108 ms
内存:11852 KiB

输入文件(test17.in

822
910737269 716472968 977953810 365339054 698675636 153790624 759216350 219882228 745671116 18937
<8046 bytes omitted>

答案文件(test17.out

167274

用户输出

167274

系统信息

Exited with return code 0
测试点 #18
Accepted
得分:100
用时:111 ms
内存:11996 KiB

输入文件(test18.in

1508
134491993 216354220 491335292 343810419 848113190 263344345 876395005 549049141 387161158 7807
<14800 bytes omitted>

答案文件(test18.out

551733

用户输出

551733

系统信息

Exited with return code 0
测试点 #19
Accepted
得分:100
用时:116 ms
内存:11848 KiB

输入文件(test19.in

1947
740493331 948416682 434429002 348479254 92471859 605014686 371477453 667980039 721033305 17292
<19143 bytes omitted>

答案文件(test19.out

946102

用户输出

946102

系统信息

Exited with return code 0
测试点 #20
Accepted
得分:100
用时:89 ms
内存:10656 KiB

输入文件(test20.in

233
893638095 980382467 388590300 54221478 441088311 33481114 703552667 948897261 335461305 4610737
<2218 bytes omitted>

答案文件(test20.out

12867

用户输出

12867

系统信息

Exited with return code 0