【CCF历年题题解】201812-1 小明上学

看懂样例

#include <iostream>

using namespace std;

int main()
{
    
    
    int r,y,g;
    cin >> r >> y >> g;
    
    int n;
    cin >> n;
    int sum = 0;
    
    for(int i=0;i<n;i++)
    {
    
    
        int k,t;
        cin >> k >> t;
        if(k == 0) sum+= t;
        else if(k == 1) sum += t;
        else if(k == 2) sum += t + r;
        else sum += 0;
    }
    
    cout<<sum<<endl;
    
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43154149/article/details/108011997