Submission #1340015

#TimeUsernameProblemLanguageResultExecution timeMemory
1340015caveeeeTezina (COCI26_tezina)C++20
36 / 70
2094 ms3408 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N, k; cin >> N >> k;
    map<int, int>m;

    for(int i = 0; i<N; i++){
        int temp; cin >> temp;
        m[temp]++;
    }

    long long ans = 0;

    for(auto[weight, ocurrances]: m){
        //cout << key << " " << val << '\n';
    
        for(int i = 1; i<=k; i++){
            if(i > weight){
                break;
            }

            long long temp = weight/i;
            long long str = min(temp*(weight+2), (long long)1e8);

            ans += str*ocurrances;
        }
    }

    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...