제출 #1319138

#제출 시각아이디문제언어결과실행 시간메모리
1319138tkm_algorithmsDetecting Molecules (IOI16_molecules)C++20
10 / 100
0 ms404 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; using ll = long long; //#define int ll using P = pair<int, int>; #define all(x) x.begin(), x.end() #define rep(i, l, n) for (int i = l; i < (n); ++i) #define sz(x) (int)x.size() const char nl = '\n'; const int mod = 1e9+7; vector<int> find_subset(int l, int u, vector<int> w) { vector<P> nw; int n = sz(w); rep(i, 0, n)nw.push_back(P(w[i], i)); sort(all(nw)); int sm = 0; priority_queue<P> pq; for (int i = n-1; i >= 0; --i) { sm += nw[i].first; pq.push(nw[i]); if (sm >= l)break; } //cout << sm << nl; vector<int> av; for (int i = n-sz(pq)-1; i >= 0; --i) { av.push_back(nw[i].second); //cout << nw[i].first << nl; } if (sm < l || nw[0].first > u)return {}; while (sm > u) { sm -= pq.top().first; pq.pop(); int i = av.back(); av.pop_back(); sm += w[i]; pq.push(P(w[i], i)); } vector<int> res; if (l <= sm && sm <= u) while (!pq.empty()) { res.push_back(pq.top().second); pq.pop(); } return res; } //int main() { //int n; cin >> n; //vector<int> w(n); //for (auto &i: w)cin >> i; //int l, u; cin >> l >> u; //vector<int> res = find_subset(l, u, w); //set<int> s; //for (auto i: res)s.insert(i); //int sm = 0; //for (auto i: res)sm += w[i]; //if (sz(s) == sz(res) && !res.empty() && sm >= l && sm <= u)cout << "YES" << nl; //else cout << "NO" << nl; //return 0; //}

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

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...