Submission #105931

# Submission time Handle Problem Language Result Execution time Memory
105931 2019-04-15T18:30:30 Z asifthegreat Growing Trees (BOI11_grow) C++14
40 / 100
1000 ms 2424 KB
#include <bits/stdc++.h>
#define int long long 
#define all(v) v.begin(),v.end()
#define keepUnique(a) sort(all(a));v.erase(unique(all(v)),v.end())
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
const int N = 100000;
int ara[N],temp[N];
 
int32_t main()
{
    int n,m,c,h;
    cin >> n >> m;
 
    for(int i = 0; i < n;i++){
        cin >> ara[i];
    }
    sort(ara,ara+n);
    char ch;
 
    while(m--){
        cin >> ch;
        if(ch == 'F'){
            //cout << "hola\n";
            cin >> c >> h;
            int pos = 0;
            int lower = lower_bound(ara,ara+n,h)-ara;
            for (int i = lower; i < n and i < lower+c; i++){
                ara[i]++;
                temp[pos++] = ara[i];
            }
            int k = pos;
            int j = min(n,lower+c);
            int i = 0;
            pos = lower;
            for(;;){
                if(pos == n)break;
                else if(j == n)ara[pos++] = temp[i++];
                else if(i == k)ara[pos++] = ara[j++];
                else if(temp[i] < ara[j]){
                    ara[pos++] = temp[i++];
                }
                else ara[pos++] = ara[j++];
            }
            //for(i = 0; i < n;i++){
                //cout << ara[i] << " ";
            //}cout << endl;
        }
        else{
            cin >> c >> h;
            int lower = lower_bound(ara,ara+n,c)-ara;
            int upper = upper_bound(ara,ara+n,h)-ara;
            cout << upper-lower << endl;
        }
    }
 
 
 
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 1792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 9 ms 444 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 10 ms 384 KB Output is correct
5 Correct 182 ms 1528 KB Output is correct
6 Correct 313 ms 1680 KB Output is correct
7 Correct 20 ms 512 KB Output is correct
8 Correct 159 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 231 ms 868 KB Output is correct
2 Correct 274 ms 1912 KB Output is correct
3 Correct 17 ms 512 KB Output is correct
4 Correct 210 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 292 ms 864 KB Output is correct
2 Correct 242 ms 1912 KB Output is correct
3 Correct 78 ms 512 KB Output is correct
4 Correct 347 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 1796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 1892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 1952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 340 ms 2424 KB Output is correct