제출 #800311

#제출 시각아이디문제언어결과실행 시간메모리
800311LIFDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms312 KiB
#include "molecules.h" #include<bits/stdc++.h> //some tricks : //if we want to check if the sum of set can reach : [l,r], we can find it maxn, it minn , //sometimes it will useful , but sometimes not. //in this cases : it is useful since the max element of the set subtract the min element of the set is less than r-l, so it will not skip the range. using namespace std; pair<long long int,int> a[300005]; long long int suf[300005]; long long int pre[300005]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { for(int i=0;i<w.size();i++) { a[i+1].first = w[i]; a[i+1].second = i; } sort(a+1,a+w.size()+1); int n = w.size(); for(int i=1;i<=n;i++)pre[i] = pre[i-1] + a[i].first; for(int i=n;i>=1;i--)suf[i] = suf[i+1] + a[i].first; bool flag = false; int k = 0; for(int i=1;i<=n;i++) { if(pre[i] <= u && suf[i] >= l) { k = i; flag = true; } } vector<int> ans; if(flag == false)return ans; for(int i=k;i<=n;i++) { if(pre[i] - pre[i-k] >= l && pre[i] - pre[i-k] <= u) { for(int j=i-k+1;j<=i;j++)ans.push_back(a[j].second); break; } } return ans; }

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

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