美团校园招聘笔试真题--第一天(未完成)

This commit is contained in:
huangge1199 2021-08-23 16:51:34 +08:00
parent 1817762271
commit 6131c97c37
3 changed files with 287 additions and 0 deletions

View File

@ -0,0 +1,93 @@
package study.plan.meituan;
import java.io.*;
import java.util.*;
public class Main {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
solve();
pw.close();
}
public static void solve() throws IOException {
int T = sc.nextInt();
while(T-- > 0){
String s = sc.next();
if(s.length() == 0){
pw.println("Wrong");
continue;
}
if(!Character.isLetter(s.charAt(0))){
pw.println("Wrong");
continue;
}
boolean flag = true;
boolean hasLetter = false;
boolean hasDigit = false;
for (int i = 0; i < s.length(); i++) {
if(!(Character.isLetter(s.charAt(i)) || Character.isDigit(s.charAt(i)))){
flag = false;
break;
}
if(Character.isLetter(s.charAt(i))){
hasLetter = true;
}
if(Character.isDigit(s.charAt(i))){
hasDigit = true;
}
}
if(flag && hasLetter && hasDigit){
pw.println("Accept");
}else{
pw.println("Wrong");
}
}
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader f) {
br = new BufferedReader(f);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public int[] nextIntArr(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
}
}

View File

@ -0,0 +1,101 @@
package study.plan.meituan.meituan001;
import java.io.*;
import java.util.StringTokenizer;
/**
* @ClassName Solution
* @Description TODO
* @Author huangge1199
* @Date 2021/8/23 15:21
**/
class Solution {
static Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
sc = new Scanner(System.in);
pw = new PrintWriter(System.out);
solve();
pw.close();
}
public static void solve() throws IOException {
int num = sc.nextInt();
while (num-- > 0) {
String username = sc.next();
if (username.length() == 0) {
pw.println("Wrong");
continue;
}
if (!Character.isLetter(username.charAt(0))) {
pw.println("Wrong");
continue;
}
boolean[] flag = new boolean[2];
boolean wrong = false;
for (int i = 0; i < username.length() && !wrong; i++) {
if (Character.isLetter(username.charAt(i))) {
flag[0] = true;
} else if (Character.isDigit(username.charAt(i))) {
flag[1] = true;
} else {
wrong = true;
break;
}
}
if(!(flag[0]&&flag[1])){
pw.println("Wrong");
continue;
}
if(wrong){
pw.println("Wrong");
}else{
pw.println("Accept");
}
}
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader f) {
br = new BufferedReader(f);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public int[] nextIntArr(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
}
}

View File

@ -0,0 +1,93 @@
package study.plan.meituan.meituan002;
import javafx.util.Pair;
import java.io.*;
import java.util.*;
/**
* @ClassName Solution
* @Description TODO
* @Author huangge1199
* @Date 2021/8/23 15:39
**/
class Solution {
static Solution.Scanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
sc = new Solution.Scanner(System.in);
pw = new PrintWriter(System.out);
solve();
pw.close();
}
public static void solve() throws IOException {
int num = sc.nextInt();
int index = 0;
int[] sums = new int[num];
while (index < num) {
sums[index] = index == 0 ? sc.nextInt() : sums[index - 1] + sc.nextInt();
index++;
}
index = 0;
while (index < num) {
int remove = sc.nextInt();
for (int i = remove; i < num; i++) {
sums[i] -= sums[remove - 1];
}
sums[remove - 1] = 0;
int max = Integer.MAX_VALUE;
for (int i = 0; i < num; i++) {
max = Math.max(max,sums[i]);
}
pw.println(max);
index++;
}
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader f) {
br = new BufferedReader(f);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public int[] nextIntArr(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
}
}