arrow_forward همه ارسال‌ها

جزئیات ارسال کد#828

code_blocks
مسئله مربوطه: رستگاری آرتور (#1) arrow_outward
verified
وضعیت داوری نهایی: محدودیت زمان تست 7
terminal
زبان برنامه‌نویسی: Java
schedule
ارسال‌کننده و زمان:
khashayar moeinfar (۱ سال پیش)
descriptionMain.java ۳۶ خط • ۱٫۲ کیلوبایت
1////TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
2//// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
3//void main() {
4// //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
5// // to see how IntelliJ IDEA suggests fixing it.
6// IO.println(String.format("Hello and welcome!"));
7//
8// for (int i = 1; i <= 5; i++) {
9// //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
10// // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
11// IO.println("i = " + i);
12// }
13//}
14
15
16import java.util.Scanner;
17public class Main {
18 public static void main(String[] args) {
19 Scanner sc = new Scanner(System.in);
20 int n = sc.nextInt();
21
22// int m = sc.nextInt();
23
24 int[] arr = new int[n];
25 for (int i=0; i<n; i++){
26 arr[i]=sc.nextInt();
27 }
28
29 int bullet =0;
30 for (int i=0;i<n/2;i++){
31 bullet+= Math.abs(arr[i]-arr[n-i-1]);
32 }
33
34 System.out.print(bullet);
35 }
36}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8