# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955648 | n3rm1n | Growing Trees (BOI11_grow) | C++17 | 1056 ms | 6884 KiB |
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>
#define endl '\n'
using namespace std;
const int MAXN = 1e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m;
int a[MAXN];
multiset < int > s;
void read_array()
{
cin >> n >> m;
for (int i = 1; i <= n; ++ i)
{
cin >> a[i];
s.insert(a[i]);
}
}
void solve()
{
char type;
int x, y;
while(m --)
{
cin >> type >> x >> y;
if(type == 'F')
{
multiset < int >::iterator it = s.lower_bound(y);
vector < int > g;
int cnt = 0;
for (multiset < int >:: iterator i = it; i != s.end();)
{
cnt ++;
int val = *i;
g.push_back(val);
if(cnt == x)break;
std::advance(i, 1);
}
for (int i = 0; i < g.size(); ++ i)
{
s.erase(s.find(g[i]));
s.insert(g[i] + 1);
}
}
else
{
int cut = std::distance(s.begin(), s.lower_bound(x)) - 1;
int add = std::distance(s.begin(), s.upper_bound(y)) - 1;
cout << add - cut << endl;
}
}
}
int main()
{
speed();
read_array();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |
# | 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... |