結果

問題 No.1233 割り切れない気持ち
ユーザー 37zigen37zigen
提出日時 2020-09-21 05:53:27
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 677 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 74,252 KB
実行使用メモリ 71,956 KB
最終ジャッジ日時 2023-09-06 16:54:04
合計ジャッジ時間 15,187 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
60,264 KB
testcase_01 AC 132 ms
55,896 KB
testcase_02 AC 142 ms
53,672 KB
testcase_03 AC 205 ms
58,312 KB
testcase_04 AC 204 ms
58,284 KB
testcase_05 AC 143 ms
56,056 KB
testcase_06 AC 144 ms
55,624 KB
testcase_07 AC 448 ms
60,424 KB
testcase_08 AC 525 ms
60,076 KB
testcase_09 AC 710 ms
66,580 KB
testcase_10 AC 682 ms
66,788 KB
testcase_11 AC 409 ms
60,412 KB
testcase_12 AC 706 ms
66,676 KB
testcase_13 AC 706 ms
66,744 KB
testcase_14 AC 726 ms
66,668 KB
testcase_15 AC 727 ms
68,528 KB
testcase_16 AC 725 ms
67,020 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] A=new int[N];
		int[] s=new int[(int)2e5+1];
		long ans=0;
		for (int i=0;i<N;++i) {
			A[i]=sc.nextInt();
			s[A[i]]++;
			ans+=1L*A[i]*N;
		}
		for (int i=s.length-2;i>=0;--i) {
			s[i]+=s[i+1];
		}
		for (int i=0;i<N;++i) {
			for (int a=A[i];a<s.length;a+=A[i]) {
				ans-=1L*s[a]*A[i];
			}
		}
		System.out.println(ans);
		
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}
0