제출 #737327

#제출 시각아이디문제언어결과실행 시간메모리
737327AmaarsaaDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
//#include "molecules.h" #include<bits/stdc++.h> using namespace std; using ll = long long; ll a[200004]; vector<int> find_subset(int l, int u, vector<int> w) { int p, sum, s, j, r, i; vector < pair < int, int > > v; for ( i = 0; i < w.size(); i ++) v.push_back(make_pair(w[i], i)); sort (v.begin(), v.end()); s = 0; a[0] = v[0].first; w[0] = a[0]; for ( i = 1; i < w.size(); i ++) { w[i] = v[i].first; a[i] = a[i - 1] + v[i].first; } vector < int > Ans; p = -1; sum = 0; for (i = 0; i < w.size(); i ++) { while (sum < l && p < v.size() - 1) { p ++; sum += w[p]; } if (sum >= l && sum <= u && w[p] - w[i] <= u - l) { for ( j = i; j <= p; j ++) { Ans.push_back(v[j].second); } break; } sum -= w[i]; } return Ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for ( i = 0; i < w.size(); i ++) v.push_back(make_pair(w[i], i));
      |               ~~^~~~~~~~~~
molecules.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for ( i = 1; i < w.size(); i ++) {
      |               ~~^~~~~~~~~~
molecules.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (i = 0; i < w.size(); i ++) {
      |              ~~^~~~~~~~~~
molecules.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   while (sum < l && p < v.size() - 1) {
      |                     ~~^~~~~~~~~~~~~~
molecules.cpp:9:14: warning: variable 's' set but not used [-Wunused-but-set-variable]
    9 |  int p, sum, s, j, r, i;
      |              ^
molecules.cpp:9:20: warning: unused variable 'r' [-Wunused-variable]
    9 |  int p, sum, s, j, r, 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...