Submission #151798

#TimeUsernameProblemLanguageResultExecution timeMemory
151798qkxwsmDetecting Molecules (IOI16_molecules)C++14
100 / 100
110 ms7224 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() #define MAXN 200013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; ll L, R; pair<ll, int> arr[MAXN]; vi ans; vi find_subset(int l, int u, vi w) { L = l; R = u; N = SZ(w); FOR(i, 0, N) { arr[i] = {w[i], i}; } sort(arr, arr + N); ll sum = 0, iter = 0; FOR(i, 0, N) { while(iter < N && sum < L) { sum += arr[iter].fi; iter++; } if (L <= sum && sum <= R) { FOR(j, i, iter) { ans.PB(arr[j].se); } break; } sum -= arr[i].fi; } return ans; }
#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...