Submission #105929

# Submission time Handle Problem Language Result Execution time Memory
105929 2019-04-15T18:28:47 Z asifthegreat Growing Trees (BOI11_grow) C++14
0 / 100
1000 ms 59048 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);
#define debug(a) cout << #a << " = " << a << endl;
using namespace std;
 
const int N = 100000;
int ara[N],temp[N];
 
int32_t main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    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;
           // cout << ara[lower] << " " << h <<  endl;
            debug(lower);
            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 1063 ms 47156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 41416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 42808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 43692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 43404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 35836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 55340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 44636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 59048 KB Time limit exceeded