제출 #1355656

#제출 시각아이디문제언어결과실행 시간메모리
1355656Charizard2021Detecting Molecules (IOI16_molecules)C++20
컴파일 에러
0 ms0 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w){
    long long n = (long long)w.size();
    map<long long, long long> cnts;
    vector<long long> srt;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        srt.push_back(w[i]);
        cnts[w[i]]++;
        sum += w[i];
    }
    sort(srt.begin(), srt.end());
    reverse(srt.begin(), srt.end());
    for(int i = 0; i < n; i++){
        if(sum - srt[i] >= l){
            sum -= srt[i];
            cnts[srt[i]]--;
        }
    }
    if(sum <= u){
        map<long long, long long> cur;
        vector<int> res;
        for(int i = 0; i < n; i++){
            if(cur[w[i]] < cnts[w[i]]){
                res.push_back(i);
                cur[w[i]]++;
            }
        }
        return res;
    }
    else{
        vector<long long> res;
        return res;
    }
}
// int main(){
//     int l, u;
//     cin >> l >> u;
//     int n;
//     cin >> n;
//     vector<int> w(n);
//     for(int i = 0; i < n; i++){
//         cin >> w[i];
//     }
//     vector<int> res = find_subset(l, u, w);
//     for(int j : res){
//         cout << j << " ";
//     }
//     cout << "\n";
// }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:35:16: error: could not convert 'res' from 'vector<long long int>' to 'vector<int>'
   35 |         return res;
      |                ^~~
      |                |
      |                vector<long long int>