제출 #851282

#제출 시각아이디문제언어결과실행 시간메모리
851282askowDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=w.size(); int subtask1=0; set<int>s; for(int i=0;i<n;i++)s.insert(w[i]); int C=0; for(int i=0;i<n;i++)C+=w[i]; if(C<l)return {}; if(s.size()==1)subtask1=1; if(subtask1){ int pref[n]; pref[0]=w[0]; for(int i=1;i<n;i++)pref[i]=pref[i-1]+w[i]; vector<int>ans; for(int i=0;i<n;i++){ int l=i,r=n-1,p=-1; while(l<=r){ int mid=(l+r)/2; int C=-1; if(i==0)C=pref[mid]; else C=pref[mid]-pref[i-1]; if(C>u)r=mid-1; else { l=mid+1; p=mid; } } if(p==-1)break; if(pref[p]-pref[i-1]>=l){ for(int j=i;j<=p;j++)ans.push_back(j); return ans; } } } }/* int main(){ int n,u,v; cin>>n>>u>>v; vector<int>a(n); for(int i=0;i<n;i++)cin>>a[i]; for(auto it:find_subset(u,v,a))cout<<it<<" "; }*/

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:13: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     set<int>s;
      |             ^
#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...