webtechbharat

codeforces 282A Solution A. Bit++ (codeforces 282A) (rank 800*)

 282A. Bit++


Problem Link: https://codeforces.com/problemset/problem/282/A


Solution 1:

import java.util.*;

public class A282 {
    public static Scanner scn = new Scanner(System.in);

    public static int finalAns(int n){
        String str = “”;
        int ans = 0;
        for(int i=0;i<n;i++){
            str=scn.next();

            if(str.charAt(0)==‘+’ || str.charAt(2)==‘+’ans++;
            else ans–;
        }

        return ans;
    }

    public static void main(String[] argv){
        int n = scn.nextInt();
        System.out.println(finalAns(n));
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.