Menu

Informatics Задача №112692. Язык PJ

February 17, 2017 - informatics.mccme.ru

Language: C++

#include<stdio.h>
#include<vector>

int main() {
    std::vector<int> sum;
    long long res = 0;
    char command[10];
    int line, count;
    sum.push_back(0);
    while(scanf("%10s", command) > 0) {
        if(command[0] == 'p') {
            scanf("%d", &count);
            sum.push_back(sum.back() + count);
        } else {
            scanf("%d %d", &line, &count);
            sum.push_back(sum.back());
            res += (long long)count * (sum.back() - sum[line - 1]);
        }
    }
    printf("%lld", res + sum.back());
    return 0;
}

(20)

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VK

Author of this post : UnknownA AuthorA

Leave a Reply

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