Submission #3007928
Source Code Expand
import java.util.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main{ static final long mod=1000000007; public static void main(String[] args) throws Exception, IOException{ Reader sc = new Reader(System.in); PrintWriter out=new PrintWriter(System.out); // int n=sc.nextInt(); // char c[][] = new char[h][w]; // char c[]=sc.nextString().toCharArray(); // for(int i=0; i<n; i++) {d[i]=sc.nextInt();} int n=sc.nextInt(); int m=sc.nextInt(); long px=sc.nextInt(); long sx=0,sy=0; for (int i=1; i<n; i++) { long e=sc.nextInt(); sx+=(e-px)*i*(n-i)%mod; sx%=mod; px=e; } px=sc.nextInt(); for (int i=1; i<m; i++) { long e=sc.nextInt(); sy+=(e-px)*i*(m-i)%mod; sy%=mod; px=e; } out.println(sx*sy%mod); out.flush(); } static void db(Object... os){ System.err.println(Arrays.deepToString(os)); } } class P implements Comparable<P>{ int id, d; P(int id, int d) { this.id=id; this.d=d; } public int compareTo(P p){ return d-p.d; //des } } class Reader { private BufferedReader x; private StringTokenizer st; public Reader(InputStream in) { x = new BufferedReader(new InputStreamReader(in)); st = null; } public String nextString() throws IOException { while( st==null || !st.hasMoreTokens() ) st = new StringTokenizer(x.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(nextString()); } public long nextLong() throws IOException { return Long.parseLong(nextString()); } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } }
Submission Info
Submission Time | |
---|---|
Task | D - ### |
User | mukku |
Language | Java8 (OpenJDK 1.8.0) |
Score | 500 |
Code Size | 2150 Byte |
Status | AC |
Exec Time | 252 ms |
Memory | 44588 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt |
All | 0_000.txt, 0_001.txt, max.txt, min.txt, mod.txt, n2.txt, rndA.txt, rndB.txt, rndC.txt, rndD.txt, rndE.txt, rndF.txt, rndG.txt, rndH.txt, rndI.txt, rndJ.txt, var.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 69 ms | 19156 KB |
0_001.txt | AC | 70 ms | 17876 KB |
max.txt | AC | 252 ms | 44588 KB |
min.txt | AC | 70 ms | 18772 KB |
mod.txt | AC | 193 ms | 34992 KB |
n2.txt | AC | 177 ms | 35636 KB |
rndA.txt | AC | 236 ms | 37632 KB |
rndB.txt | AC | 238 ms | 35564 KB |
rndC.txt | AC | 247 ms | 38512 KB |
rndD.txt | AC | 229 ms | 38212 KB |
rndE.txt | AC | 240 ms | 38596 KB |
rndF.txt | AC | 239 ms | 37968 KB |
rndG.txt | AC | 241 ms | 37136 KB |
rndH.txt | AC | 248 ms | 40628 KB |
rndI.txt | AC | 234 ms | 36768 KB |
rndJ.txt | AC | 250 ms | 38728 KB |
var.txt | AC | 249 ms | 40176 KB |