Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.lang.*;
- /**
- * Kattis - gamerank - Game Rank
- * Ad hoc
- */
- public class Main {
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- StringBuilder sb = new StringBuilder();
- String str = br.readLine();
- int r = 25;
- int star = 0;
- int streak = 0;
- for(int i = 0; i < str.length(); i++){
- if(str.charAt(i) == 'W'){
- streak++;
- if(streak > 2 && r > 5){
- star+=2;
- }else{
- star++;
- }
- if(r > 20){
- if(star > 2){
- r--;
- star = star - 2;
- }
- }else if(r > 15){
- if(star > 3){
- r--;
- star = star - 3;
- }
- }else if(r > 10){
- if(star > 4){
- r--;
- star = star - 4;
- }
- }else{
- if(star > 5){
- r--;
- star = star - 5;
- }
- }
- if(r < 1){
- System.out.println("Legend");
- return;
- }
- }else{
- streak = 0;
- if(r < 21){
- star--;
- }else{
- continue;
- }
- if(star < 0){
- if(r > 19){
- star = 0;
- }else if(r > 14){
- star = 2;
- r++;
- }else if(r > 9){
- star = 3;
- r++;
- }else{
- star = 4;
- r++;
- }
- }
- }
- }
- System.out.println(r);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment