跳到正文

个人记录

B. 【一月份 -- 基础语法组】-- T2 --可爱数字

zhangyuqiTAT约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年4月12日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟

版本

  1. v1当前

网址: https://cspjs.online/contest/648/problem/2

题解: https://b1bznc26af6.feishu.cn/file/GPkxb1gqwowN1Gxc9E5c0bpnntb?from=from_copylink

C++
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int c[200010];
signed main() {
    freopen("cute.in", "r", stdin);
    freopen("cute.out", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        memset(c, 0, sizeof c);
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            c[a[i]]++;
        }
        long long mx = 0;
        for (int i = 1; i <= n; i++) {
            mx = max(mx, (long long)i * c[i]);
        }
        cout << mx << '\n';
    }
}
原文