結果

問題 No.1618 Convolution?
ユーザー merlinmerlin
提出日時 2021-07-22 22:18:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 748 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 4,227 ms
コンパイル使用メモリ 74,588 KB
実行使用メモリ 84,476 KB
最終ジャッジ日時 2023-09-24 17:26:35
合計ジャッジ時間 17,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
50,800 KB
testcase_01 AC 67 ms
50,552 KB
testcase_02 AC 615 ms
81,688 KB
testcase_03 AC 580 ms
84,476 KB
testcase_04 AC 545 ms
70,544 KB
testcase_05 AC 187 ms
55,860 KB
testcase_06 AC 702 ms
80,076 KB
testcase_07 AC 729 ms
80,796 KB
testcase_08 AC 544 ms
68,616 KB
testcase_09 AC 695 ms
80,408 KB
testcase_10 AC 538 ms
66,792 KB
testcase_11 AC 678 ms
79,012 KB
testcase_12 AC 697 ms
78,760 KB
testcase_13 AC 686 ms
67,100 KB
testcase_14 AC 686 ms
77,972 KB
testcase_15 AC 719 ms
66,408 KB
testcase_16 AC 748 ms
70,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int i,a[]=new int[n+1],b[]=new int[n+1];
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++) a[i+1]=Integer.parseInt(s[i]);
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++) b[i+1]=Integer.parseInt(s[i]);

        long pa=0,pb=0,ca=0,cb=0,c[]=new long[2*n+1];
        for(i=2;i<=2*n;i++)
        {
            if(i-1<=n)
            {
                pa+=a[i-1];pb+=b[i-1];
                ca+=pa; cb+=pb;
            }
            else
            {
                pa-=a[i-n-1]; ca-=1l*n*a[i-n-1];
                pb-=b[i-n-1]; cb-=1l*n*b[i-n-1];
                ca+=pa; cb+=pb;
            }
            c[i]=ca+cb;
        }

        for(i=1;i<=2*n;i++) sb.append(c[i]+" ");
        System.out.print(sb);
    }
}
0