zzzxxzxzxzx

来源:互联网 发布:优化软件下载 编辑:程序博客网 时间:2024/05/21 17:27
import java.util.Scanner;


public class Main {
static int[] palyer = new int[2];
static summon[][] fild = new summon[2][7 + 1];
static int[] num = new int[2];


public static void main(String[] args) {
for (int i = 0; i < 2; ++i) {
palyer[i] = 30;
num[i] = 0;
}


Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.nextLine();
int flag = 0;
for (int i = 0; i < n; ++i) {
String type = in.next();
if (type.equals("summon")) {
int position = in.nextInt();
int a = in.nextInt();
int h = in.nextInt();
in.nextLine();
num[flag]++;
if (num[flag] != 0) {
for (int j = num[flag]; j > position; --j) {
fild[flag][j] = fild[flag][j - 1];
}
}

fild[flag][position] = new summon(a, h);
} else if (type.equals("attack")) {
int from = in.nextInt();
int to = in.nextInt();
in.nextLine();
if (to == 0) {
palyer[1 - flag] -= fild[flag][from].a;
if (palyer[1 - flag] <= 0) {
break;
}
} else {
fild[flag][from].h -= fild[1 - flag][to].a;
fild[1 - flag][to].h -= fild[flag][from].a;
if (fild[flag][from].h <= 0) {

for (int j = from; j < num[flag]; ++j) {
fild[flag][j] = fild[flag][j + 1];
}
num[flag]--;
}
if (fild[1 - flag][to].h <= 0) {

for (int j = to; j < num[1 - flag]; ++j) {
fild[1 - flag][j] = fild[1 - flag][j + 1];
}
num[1 - flag]--;
}
}
} else if (type.equals("end")) {
flag = 1 - flag;
}
}
if (palyer[0] <= 0) {
System.out.println("1");
} else if (palyer[1] <= 0) {
System.out.println("-1");
} else {
System.out.println("0");
}


System.out.println(palyer[0]);
System.out.print(num[0] + " ");
for (int i = 1; i <= num[0]; ++i) {
System.out.print(fild[0][i].h + " ");
}
System.out.println();


System.out.println(palyer[1]);
System.out.print(num[1] + " ");
for (int i = 1; i <= num[1]; ++i) {
System.out.print(fild[1][i].h + " ");
}
}


}


class summon {
int a;
int h;


public summon(int a, int h) {
super();
this.a = a;
this.h = h;
}

}



import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {
public static void main(String[] args) {


Scanner in = new Scanner(System.in);
int n = in.nextInt();
int q = in.nextInt();
Point[] points = new Point[n];
ArrayList<Integer> row = new ArrayList<Integer>();
ArrayList<Integer> col = new ArrayList<Integer>();
for(int i=0;i<n;++i){
int x = in.nextInt();
int y = in.nextInt();
if(!row.contains(x)){
row.add(x);
}
if(!col.contains(y)){
col.add(y);
}
points[i] = new Point(x, y);
}
Point[][] mp = new Point[row.size()][col.size()];
Collections.sort(row);
Collections.sort(col);
for(int i = 0;i<n;++i){
int xx = Collections.binarySearch(row, points[i].x);
int yy = Collections.binarySearch(col, points[i].y);
mp[xx][yy] = points[i];
}
int maxLevel=0;
int maxNum=0;
for(int i=0;i<row.size();++i){
for(int j=0;j<col.size();++j){
if(mp[i][j]!=null){
continue;
}
int a=0,b=0,c=0,d=0;
for(int m=0;m<i;++m){
if(mp[m][j]!=null){
++a;
}
}
for(int m=i+1;m<col.size();++m){
if(mp[m][j]!=null){
++b;
}
}
for(int m=0;m<j;++m){
if(mp[i][m]!=null){
++c;
}
}
for(int m=j+1;m<row.size();++m){
if(mp[i][m]!=null){
++d;
}
}
int tempLevel = Math.min(Math.min(a, b),Math.min(a, b));
if(tempLevel==maxLevel){
++maxNum;
}else if(tempLevel>maxLevel){
maxLevel = tempLevel;
maxNum = 1;
}
}
}
if(q==1){
System.out.println(maxLevel);
}else if (q==2) {
System.out.println(maxNum);
}
}


}
class Point{
int x;
int y;
public Point(int x, int y) {
super();
this.x = x;
this.y = y;
}
}


import java.util.Scanner;


public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] mp = new int[21][6];
for(int i = 1;i<=20;++i){
mp[i][0] = 5;
}
for (int i = 0; i < n; ++i) {
int p = in.nextInt();
int j;//j is row,start with 1.
for (j = 1; j <= 20; ++j) {
if (mp[j][0] >= p) {
for (int x = 1; x <= p; ++x) {
int num = (j-1)*5+ 6-mp[j][0];
System.out.print(num+" ");
--mp[j][0];
}
System.out.println();
break;
}
}
if (j > 20) {
for (int y = 1; y <= 20 && p > 0; ++y) {
while (mp[y][0] > 0) {
int num = (y-1)*5+6-mp[y][0];
System.out.print(num+" ");
--mp[y][0];
--p;
}
}
System.out.println();
}
}
}


}



import java.util.Scanner;


public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int max = 0;
int[] mm = new int[n];
for(int i=0;i<n;++i){
mm[i] = in.nextInt();
}
for(int i=1;i<n;++i){
int temp = mm[i]-mm[i-1];
if(temp<0){
temp = -temp;
}
if(temp>max){
max = temp;
}
}
System.out.println(max);
}


}

0 0