1 条题解

  • 0
    @ 2025-10-8 16:54:51
    #include <bits/stdc++.h>
    using namespace std;
    struct node
    {
        string name;
        int a, b;
        node(){a=0, b=0;}
    }P[15];
    string s;
    int n;
    map<string, int>mp;
    int main()
    {
        cin >> n;
        for(int i=1; i<=n; i++)cin >> P[i].name, mp[P[i].name] = i;
        for(int i=1; i<=n; i++)
        {
            cin >> s;
            int x=mp[s];
            int wi, pi; cin >> wi >> pi; if(pi==0)continue;
            int t=wi/pi;
            P[x].a = t*pi;
            for(int j=1; j<=pi; j++)
            {
                cin >> s;
                int y=mp[s];
                P[y].b += t;
            }
        }
        for(int i=1; i<=n; i++) cout << P[i].name << " " << P[i].b - P[i].a << endl;
        return 0;
    }
    
    • 1

    【字符串基础】字符串map[USACO1.1]Greedy Gift Givers

    信息

    ID
    980
    时间
    1000ms
    内存
    128MiB
    难度
    4
    标签
    递交数
    104
    已通过
    52
    上传者