Submission #490497

#TimeUsernameProblemLanguageResultExecution timeMemory
490497MohamedAliSaidaneDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> //#include "molecules.h" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<pld> vpd; #define pb push_back #define popb pop_back #define all(v) (v).begin(),(v).end() #define ff first #define ss second const ll MOD = 1e9 + 7; const ll INF = 1e18; int nx[4] = {1,-1,0,0}, ny[4] = {0,0,1,-1}; /////// SOLUTION \\\\\\\ vi find_subset(int l, int u, vi w) { vpi A; int n = w.size(); for(int i = 0; i <n; i ++) A.pb({w[i],i}); sort(all(A)); ll pref[n+1]; pref[0] = 0; for(int i= 0; i <n; i ++) pref[i+1] = pref[i] + A[i].ff; int left = 0; int right = -1; for(int k= 1; k <= n; k ++) { if(pref[k] <= l) { bool flag= false; for(int i = k; i <= n-k+1; i ++) { if(pref[i]-pref[i-k] >= l && pref[i]-pref[i-k] <= u) { flag = true; left = i; right = i + k -1; } } if(flag) break; } } vi res; for(int i = left; i <= right; i ++) res.pb(A[i].ss); return res; }

Compilation message (stderr)

molecules.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | /////// SOLUTION \\\\\\\
      | ^
#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...