Submission #919639

#TimeUsernameProblemLanguageResultExecution timeMemory
919639NurislamDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back vector<int> find_subset(int l, int r, vector<int> temp) { vector<int> ans; int n=temp.size(); vector<pair<int, int>> w; for (int i = 0; i < n; ++i) { w.push_back({temp[i], i}); } sort(w.begin(), w.end()); long long sum=0; int i = 0, j = 0, sum = 0; while(j < n){ sum+=w[j++].first; while(sum > r){ sum -= w[i++].first; } if(sum > l){ for(; i <= j; i++){ ans.pb(w[i].second); }return ans; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:17:20: error: redeclaration of 'long long int sum'
   17 |  int i = 0, j = 0, sum = 0;
      |                    ^~~
molecules.cpp:16:12: note: 'long long int sum' previously declared here
   16 |  long long sum=0;
      |            ^~~