Submission #955648

#TimeUsernameProblemLanguageResultExecution timeMemory
955648n3rm1nGrowing Trees (BOI11_grow)C++17
0 / 100
1056 ms6884 KiB
#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)

grow.cpp: In function 'void solve()':
grow.cpp:48:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for (int i = 0; i < g.size(); ++ i)
      |                             ~~^~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...