제출 #961724

#제출 시각아이디문제언어결과실행 시간메모리
961724ErJDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms544 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define pp pair<ll, ll> #define inf 1000000000000000; #define vvi vector<vi> #define vp vector<pp> #define rep(i, n) for(int i = 0; i < n; i++) #define mod 1000000007 vector<int> result; vector<int> find_subset(int l, int r, vector<int> w1) { ll n = w1.size(); vp w(n); rep(i, n) { w[i] = { w1[i], i }; } sort(w.begin(), w.end()); vi pref(n), suff(n); pref[0] = w[0].first; suff[0] = w[n - 1].first; rep(i, n - 1) { pref[i + 1] = pref[i] + w[i + 1].first; suff[i + 1] = suff[i] + w[n - i - 2].first; } set<ll> ans; result.clear(); rep(i, n) { ans.insert(i); if (pref[i] <= r && suff[i] >= l) { result.clear(); ll akt = pref[i]; if (pref[i] >= l) { auto it = ans.begin(); for (ll j = 0; j < ans.size(); j++) { result.push_back(w[*it].second); it++; } } else { for (int j = i; j >= 0; j--) { akt -= w[j].first; ans.erase(j); ll left = i; ll right = n - (i - j); ll hledam = r - akt; while (right > left + 1) { ll mid = (right + left) / 2; if (w[mid].first > hledam) { right = mid; } else { left = mid; } } akt += w[left].first; ans.insert(left); if (l <= akt && akt <= r) { auto it = ans.begin(); for (ll j = 0; j < ans.size(); j++) { result.push_back(w[*it].second); it++; } break; } } } break; } } return result; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:37:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |                 for (ll j = 0; j < ans.size(); j++) {
      |                                ~~^~~~~~~~~~~~
molecules.cpp:62:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |                         for (ll j = 0; j < ans.size(); j++) {
      |                                        ~~^~~~~~~~~~~~
#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...