제출 #525988

#제출 시각아이디문제언어결과실행 시간메모리
525988gs21045Detecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms216 KiB
#include <bits/stdc++.h> #include "molecules.h" #define endl '\n' #define F first #define S second using namespace std; typedef long long ll; typedef pair<ll,ll> pll; vector<int> find_subset(int l,int u,vector<int> a) { vector<int> result; int n=a.size(); vector<pll> w(n+1); for(int i=1; i<=n; i++) w[i].F=(ll)a[i-1],w[i].S=i; sort(w.begin()+1,w.end()); vector<ll> sum(n+1); for(int i=1; i<w.size(); i++) sum[i]=sum[i-1]+w[i].F; int st=n,en=n; while(st>0 && sum[en]-sum[st-1]<(ll)l) st--; if(sum[en]-sum[st-1]<(ll)l) return result; while(en>0 && sum[en]-sum[st-1]>(ll)u) { en--; while(st>0 && sum[en]-sum[st-1]<(ll)l) st--; } if(sum[en]-sum[st-1]<=(ll)u && sum[en]-sum[st-1]>=(ll)l) for(int i=st; i<=en; i++) result.push_back(w[i].S); return result; } /* int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,l,u; cin>>n>>l>>u; vector<int> w(n); for(int i=0; i<n; i++) cin>>w[i]; vector<int> result=find_subset(l,u,w); cout<<(int)result.size()<<endl; for(int i=0; i<(int)result.size(); i++) cout<<result[i]<<' '; return 0; } */

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=1; i<w.size(); i++) sum[i]=sum[i-1]+w[i].F;
      |                  ~^~~~~~~~~
#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...