제출 #172470

#제출 시각아이디문제언어결과실행 시간메모리
172470gs18103Detecting Molecules (IOI16_molecules)C++14
9 / 100
3 ms380 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MAX = 505050;
const int INF = INT_MAX >> 1;
const ll LINF = LLONG_MAX >> 1;
const ll mod = 1e9+9;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector <int> ans;
    vector <pii> W;
    for(int i = 0; i < w.size(); i++) W.eb(w[i], i);
    sort(all(W));
    reverse(all(W));
    int sum = 0;
    for(int i = 0; i < W.size(); i++) {
        if(sum < l && sum + W[i].fi <= u) sum += W[i].fi, ans.eb(W[i].se);
        if(sum >= l && sum <= u) break;
    }
    sort(all(ans));
    if(sum >= l && sum <= u) return ans;
    else return vector <int> {};
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < w.size(); i++) W.eb(w[i], i);
                    ~~^~~~~~~~~~
molecules.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < W.size(); i++) {
                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...