Submission #711659

#TimeUsernameProblemLanguageResultExecution timeMemory
711659JANCARAPANDetecting Molecules (IOI16_molecules)C++17
69 / 100
41 ms6448 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; //#define int long long #define fi first #define se second #define pb push_back #define all(a) (a).begin(), (a).end() #define sz(a) (long long) a.size() #define endl '\n' #define dbg(a) cerr << #a << " = " << a << endl; #define print(a) for (auto x : a) cerr << x << " "; cerr << endl; const int INF = 1e18, MOD = 1e9+7; vector<int> find_subset(int l, int r, vector<int> tmp) { int n = sz(tmp); vector<pair<int,int>> a(n); for (int i = 0; i < n; i++) { a[i] = {tmp[i], i}; } sort(all(a)); vector<int> pref(n), suff(n); for (int i = 0; i < n; i++) { pref[i] = a[i].fi + (i ? pref[i - 1] : 0); suff[n - i - 1] = a[n - i - 1].fi + (i ? suff[n - i] : 0); } vector<int> ans; for (int size = 0; size < n; size++) { if (pref[size] > r || suff[n - size - 1] < l) continue; int cur = pref[size]; int j = 0; while (cur < l) { cur += a[n - j - 1].fi - a[j].fi; j += 1; } if (cur >= l) { for (int it = j; it <= size; it++) { ans.pb(a[it].se); } for (int it = n - 1; it >= n - j; it--) { ans.pb(a[it].se); } break; } } return ans; } //signed main() { //ios_base::sync_with_stdio(0); //cin.tie(0); //vector<int> a = find_subset(15, 17, {6, 6, 8, 7}); //vector<int> a = find_subset(14, 15, {5, 5, 6, 6}); //vector<int> a = find_subset(10, 20, {15, 17, 16, 18}); //for (auto x : a) cerr << x << " "; //} //signed main() { //ios_base::sync_with_stdio(0); //cin.tie(0); //int tt = 1; //cin >> tt; //while (tt--) { //solve(); //} //return 0; //}

Compilation message (stderr)

molecules.cpp:15:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | const int INF = 1e18, MOD = 1e9+7;
      |                 ^~~~
#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...