[백준] 2506번 : 점수계산 - Dart(다트)

강재원·2022년 10월 2일
0

[코딩테스트] Dart

목록 보기
87/100



https://www.acmicpc.net/problem/2506

import 'dart:io';
void main(){
    int n=int.parse(stdin.readLineSync()!);
    int sum=0;
    int count=0;
    String? s=stdin.readLineSync();
    var v=s!.split(' ').map<int>((o)=>int.parse(o));
    for(int i=0;i<n;i++){
        int a=v.elementAt(i);
        if(a==1){
            count++;
            sum+=count;
        }
        else count=0;
    }
    print(sum);
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글