100+100+100+0.
感觉自己的代码质量贼差。
3.13 收到笔试通过。
import java.util.Arrays;
import java.util.Scanner;
/**
* @ClassName PACKAGE_NAME.Main
* @Desciption
* @Author S
* @DateTime 2019-03-10 16:34
* @Version 1.0
**/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
for (int i = 0; i < n; i++) {
b[i] = in.nextInt();
}
Arrays.sort(a);
Arrays.sort(b);
int sum = 0;
for (int i = 0; i < n; i++) {
sum += a[i] * b[n - i - 1];
}
System.out.println(sum);
}
}
import java.util.*;
/**
* @ClassName PACKAGE_NAME.Main
* @Desciption
* @Author S
* @DateTime 2019-03-10 16:34
* @Version 1.0
**/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.next();
str = str.toLowerCase();
if (str.length() <= 0) {
System.out.println();
return;
}
int[] record = new int[26];
HashMap<Character, Integer> map = new HashMap<>();
for (int i = 0; i < str.length(); i++) {
map.put(str.charAt(i), map.getOrDefault(str.charAt(i), 0) + 1);
}
char ans = str.charAt(0);
for (int i = 0; i < str.length(); i++) {
if (map.get(str.charAt(i)) < 1) {
ans = str.charAt(i);
break;
} else {
// 这里有错,应该是样例简单才通过的,参见回帖
if (i + 1 < str.length() && str.charAt(i+1) < str.charAt(i)) {
ans = str.charAt(i+1);
map.put(str.charAt(i), map.get(str.charAt(i)) - 1);
} else {
ans = str.charAt(i);
break;
}
}
}
System.out.println(ans);
}
}
import java.util.*;
/**
* @ClassName PACKAGE_NAME.Main
* @Desciption
* @Author S
* @DateTime 2019-03-10 16:34
* @Version 1.0
**/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int d = in.nextInt();
int[] a = new int[n];
int[] b = new int[n];
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
b[i] = in.nextInt();
map.put(a[i], b[i]);
}
Arrays.sort(a);
for (int i = 0; i < n; i++) {
b[i] = map.get(a[i]);
}
// i坐标 及 以后的最大的值
int[] maxN = new int[n];
maxN[n-1] = b[n-1];
for (int i = n - 2; i >= 0; i--) {
if (maxN[i+1] < b[i]) {
maxN[i] = b[i];
} else {
maxN[i] = maxN[i+1];
}
}
// 第i个银行,可选第二银行的范围;最后一个银行没有选择
int[] indexI = new int[n];
for (int i = 0; i < n; i++) {
int j = 1;
if (i != 0) {
j = indexI[i-1];
}
for (; j < n; j++) {
if (a[j] - a[i] >= d) {
indexI[i] = j;
break;
}
}
if (j == n) {
indexI[i] = -1;
for (;i < n; i++) {
indexI[i] = -1;
}
break;
}
}
int sum = 0;
for (int i = 0; i < n - 1; i++) {
if (indexI[i] == -1) {
continue;
}
int tempSum = maxN[indexI[i]] + b[i];
if (tempSum > sum) {
sum = tempSum;
}
}
System.out.println(sum);
}
}
#笔试题目##题解##拼多多##春招#