8 solutions

  • 0
    @ 2025-7-4 11:23:02

    #include #include #include

    using namespace std;

    int main() { int n; cin >> n; vector sum_t(24, 0); // 存储每个UTC小时t对应的工人总数,用long long防止溢出

    for (int i = 0; i < n; ++i) {
        int w, x;
        cin >> w >> x;
        // 当地起始小时h需在9-17之间,计算对应的UTC时间t并累加工人数量
        for (int h = 9; h <= 17; ++h) {
            int t = (h - x + 24) % 24;  // +24确保结果为非负数,再取模24得到0-23的UTC时间
            sum_t[t] += w;
        }
    }
    
    // 找到最大的工人数量
    cout << *max_element(sum_t.begin(), sum_t.end()) << endl;
    
    return 0;
    

    }

    Information

    ID
    2611
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    (None)
    # Submissions
    26
    Accepted
    6
    Uploaded By