Submission #573338

#TimeUsernameProblemLanguageResultExecution timeMemory
573338talant117408Detecting Molecules (IOI16_molecules)C++17
100 / 100
70 ms6180 KiB
#include "molecules.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define pb push_back #define mp make_pair #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define sz(v) int((v).size()) #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl '\n' int mod = 1e9+7; ll modulo(ll a) { return ((a % mod) + mod) % mod; } ll add(ll a, ll b) { return modulo(a + b); } ll mult(ll a, ll b) { return modulo(a * b); } ll binpow(ll a, ll b) { ll res = 1; while (b) { if (b&1) { res = mult(res, a); } a = mult(a, a); b >>= 1; } return res; } vector<int> find_subset(int L, int R, vector<int> w) { int l = 0; ll sum = 0; vector <pii> atoms; for (int i = 0; i < sz(w); i++) { atoms.pb(mp(w[i], i)); } sort(all(atoms)); for (int r = 0; r < sz(atoms); r++) { sum += atoms[r].first; while (sum > R) { sum -= atoms[l].first; l++; } if (L <= sum && sum <= R) { vector <int> ans; for (int i = l; i <= r; i++) { ans.pb(atoms[i].second); } return ans; } } return vector <int> (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...