제출 #881845

#제출 시각아이디문제언어결과실행 시간메모리
881845theghostkingDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms500 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 = w.size(); vector<pair<long long,long long>> vec(n); for (long long i = 0; i<n; i++){ vec[i] = {w[i],i}; } sort(vec.begin(),vec.end()); vector<bool> vis(n); long long pt = n-1; long long cr = 0; while (pt >= 0){ if (cr < l){ cr += vec[pt].first; vis[pt] = true; pt--; } if (pt < 0) break; if ((l <= cr) && (cr <= u)){ break; } int lm = pt; //can go from 0...pt, and pt+1,...,n-1 int o = 0; int r = n-1; bool dul = false; while (cr > u){ dul = true; if (o > pt) break; if (r < pt+1) break; if (!(o<r)) break; cr -= vec[r].first; cr += vec[o].first; vis[r] = false; vis[o] = true; r--; o++; } if (dul) break; if ((l <= cr) && (cr <= u)) break; } vector<int> ans; if (cr < l || cr > u){ return ans; } else{ for (long long i = 0; i<n; i++){ if (vis[i]) ans.push_back(i); } return ans; } }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:13: warning: unused variable 'lm' [-Wunused-variable]
   25 |         int lm = pt;
      |             ^~
#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...