This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
vector < int > find_subset( int l, int u, vector < int > w )
{
int n = w.size();
vector < pair < int, int > > vc(n);
forn( i, n ) {
vc[i].fi = w[i];
vc[i].se = i;
}
ll sum = 0;
vector < int > ans;
for( int i = 0, j = 0; j < n; j++ ) {
sum += vc[j].fi;
while ( sum > u ) {
sum -= vc[i++].fi;
}
if ( sum >= l ) {
fore( k, i, j + 1 ) ans.pb( vc[k].se );
break;
}
}
return ans;
}
/*
int main()
{
speed;
int l, u, n;
cin >> n >> l >> u;
vector < int > vc(n);
forn( i, n ) cin >> vc[i];
auto v = find_subset( l, u, vc );
for( auto i: v ) cout << i << endl;
time;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |