Submission #951305

#TimeUsernameProblemLanguageResultExecution timeMemory
951305chandu33Detecting Molecules (IOI16_molecules)C++17
100 / 100
50 ms4796 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_subset(int L, int U, vector<int>A) { vector<int> ans; int N = A.size(); vector<int> pos(N); iota(pos.begin(), pos.end(), 0); sort(pos.begin(), pos.end(), [&A](int a, int b){ return A[a] < A[b]; }); sort(A.begin(), A.end()); int low = 0, high = N - 1; ll sum = 0; int i = 0, j = 0; for(int i = 0; i < N; i++) { sum += A[i]; while(sum > U) { sum -= A[j++]; } if(sum >= L && sum <= U) { for(int k = j; k <= i; k++) { ans.push_back(pos[k]); } break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:6: warning: unused variable 'low' [-Wunused-variable]
   15 |  int low = 0, high = N - 1;
      |      ^~~
molecules.cpp:15:15: warning: unused variable 'high' [-Wunused-variable]
   15 |  int low = 0, high = N - 1;
      |               ^~~~
molecules.cpp:17:6: warning: unused variable 'i' [-Wunused-variable]
   17 |  int i = 0, j = 0;
      |      ^
#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...