Submission #793563

#TimeUsernameProblemLanguageResultExecution timeMemory
793563duyanhloveavGrowing Trees (BOI11_grow)C++17
30 / 100
1083 ms3336 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define int long long const int N = 9 + 1e5; const int oo = 7 + 1e9; int a[N]; void SaKaTa() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; sort (a + 1, a + 1 + n); while (m--) { char c; int l, r; cin >> c >> l >> r; if (c == 'F') { int pos = lower_bound(a + 1, a + 1 + n, r) - a; if (pos != (n + 1)) { for (int i = pos; i <= n; i++) { a[i]++; l--; if (l == 0) break; } sort (a + 1, a + 1 + n); } } else { int pos = lower_bound(a + 1, a + 1 + n, l) - a; if (pos != (n + 1) && a[pos] <= r) { int pos_two = upper_bound(a + 1, a + 1 + n, r) - a - 1; cout << pos_two - pos + 1 << '\n'; } else cout << 0 << '\n'; } } } int32_t main() { #define TASKNAME "TREE" cin.tie(0)->sync_with_stdio(0); if ( fopen( TASKNAME".inp", "r" ) ) { freopen (TASKNAME".inp", "r", stdin); freopen (TASKNAME".out", "w", stdout); } int testcase = 1; // scanf("%d", &testcase); while (testcase--) SaKaTa(); return 0; }

Compilation message (stderr)

grow.cpp: In function 'int32_t main()':
grow.cpp:47:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen (TASKNAME".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
grow.cpp:48:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen (TASKNAME".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...