Submission #1164582

#TimeUsernameProblemLanguageResultExecution timeMemory
1164582AzaDetecting Molecules (IOI16_molecules)C++20
46 / 100
2 ms584 KiB
//AzaLE (Azamat Alisherov) #include <bits/stdc++.h> #include "molecules.h" #define F first #define S second #define size(x) (int)x.size() #define all(x) x.begin(),x.end() using namespace std; vector <int> find_subset(int x, int y, vector<int> v){ int n = size(v); vector <pair<int, int>> g; for(int i = 0; i < n; i++){ g.push_back({v[i], i}); } sort(all(g)); vector <int> ps(n + 1); for(int i = 1; i <= n; i++){ ps[i] = ps[i - 1] + g[i - 1].F; } int l = n, r = n; int ansl = -1, ansr = n + 1; for(l = l; l >= 0; l--){ while(r > l and ps[l] + ps[n] - ps[r] < x)r--; int sm = ps[l] + ps[n] - ps[r]; if(sm >= x and sm <= y){ ansl = l; ansr = r; break; } } vector <int> ans; for(int i = 0; i < ansl; i++){ ans.push_back(g[i].S); } for(int i = n - 1; i >= ansr; i--){ ans.push_back(g[i].S); } return ans; } /* */

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...