B. Vasya and Wrestling
2014-12-25 19:39
225 查看
思路:
这题主要注意,就是字典序的判断。
小坑:当两队分数与序列完全一样时,谁投了最后一球谁获胜。
AC Code:
这题主要注意,就是字典序的判断。
小坑:当两队分数与序列完全一样时,谁投了最后一球谁获胜。
AC Code:
1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <cstring> 5 #include <string.h> 6 #include <math.h> 7 #include <queue> 8 #include <stack> 9 #include <stdlib.h> 10 #include <map> 11 using namespace std; 12 #define LL long long 13 #define sf(a) scanf("%d",&(a)); 14 #define N 500050 15 char name1 ,name2 ; 16 int f1 ,f2 ; 17 int t1,t2; 18 int flag=0; 19 int deal(){ 20 //判断f1 与 f2的字典序那个大。 21 int a,b;a=b=0; 22 while(a<t1 && b<t2){ 23 24 if(f1[a] == f2[b]){ 25 a++;b++; 26 continue; 27 } 28 else if(f1[a]>f2[b]) return 1; 29 else return 0; 30 31 } 32 if(t1==a && t2==b) { 33 if(flag==1) return 1; 34 else return 0; 35 } 36 if(t2==b) return 1; //t2先完了 t1长,其字典序比较大; 37 return 0; 38 } 39 int main() 40 { 41 int n;//t1=t2=0; 42 LL num1,num2;num1=num2=0; 43 scanf("%d",&n); 44 while(n--){ 45 int t; 46 scanf("%d",&t); 47 if(t>0) { 48 num1 += t; 49 flag=1; 50 f1[t1++] = t; 51 } 52 else{ 53 num2 += (-t); 54 flag=2; 55 f2[t2++] = (-t); 56 } 57 } 58 if(num1>num2) printf("first\n"); 59 else if(num1<num2) printf("second\n"); 60 else{ 61 if(deal()) printf("first\n"); 62 else printf("second\n"); 63 } 64 return 0; 65 }
相关文章推荐
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
- B. Vasya and Wrestling
- D - Vasya and Chess
- CodeForce 460A :Vasya and Socks
- CodeForces 354A - Vasya and Robot 简单思维..赋初值一定不能随便了T_T
- [思路题] Codeforces 354C #206 (Div. 1) C. Vasya and Beautiful Arrays
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
- codeforces 355C - Vasya and Robot
- CF190A:Vasya and the Bus(易错题)
- Codeforces Round #281 (Div. 2) A. Vasya and Football
- A Vasya and Football
- Codeforces Round #354 (Div. 2) C Vasya and String(尺取法二分)
- Codeforces Round #319 (Div. 2) C Vasya and Petya's Game
- cf#324 Div.2 Problem C Marina and Vasya
- CF 281div2 c题Vasya and Basketball
- Codeforces Round #324 (Div. 2) C. Marina and Vasya
- codeforces Vasya and Digital Root
- A. Vasya and Digital Root
- [CF355C]Vasya and Robot(思维,贪心)