Submission #100408

# Submission time Handle Problem Language Result Execution time Memory
100408 2019-03-11T04:14:21 Z shafinalam Growing Trees (BOI11_grow) C++14
30 / 100
1000 ms 2996 KB
#include <bits/stdc++.h>

using namespace std;

const int mx = 1e5+5;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<int,pii>piii;

#define  sf scanf
#define  pf printf

#define  input freopen("input.txt","r",stdin)
#define  output freopen("output.txt","w",stdout)

#define  inf 1e16
#define  ff first
#define  ss second
#define  MP make_pair
#define  pb push_back
#define  all(v) v.begin(), v.end()
#define  printcase(cases) printf("Case %d:", cases);
#define  Unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define  FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define  endl printf("\n")
#define  __lcm(a, b) ((a*b)/__gcd(a, b))

int  Set(int N,int pos){return N=N | (1<<pos);}
int  reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}

ll arr[mx];
char s[2];

int main()
{
    int n, m;
    sf("%d%d", &n, &m);

    for(int i = 0; i < n; i++) sf("%lld", &arr[i]);
    sort(arr, arr+n);

    while(m--)
    {

        sf("%s", s);
        if(s[0]=='F')
        {
            ll c, h;
            sf("%lld%lld", &c, &h);
            int ind = lower_bound(arr, arr+n, h)-arr;
            for(int i = ind; i < n && i < ind+c; i++) arr[i]++;
            sort(arr, arr+n);
        }
        else
        {
            ll a, b;
            sf("%lld%lld", &a, &b);
            int l = lower_bound(arr, arr+n, a)-arr;
            int r = upper_bound(arr, arr+n, b)-arr-1;
            pf("%d\n", r-l+1);
        }
    }
    return 0;
}

Compilation message

grow.cpp: In function 'int main()':
grow.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     sf("%d%d", &n, &m);
       ^
grow.cpp:42:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < n; i++) sf("%lld", &arr[i]);
                                  ^
grow.cpp:48:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         sf("%s", s);
           ^
grow.cpp:52:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             sf("%lld%lld", &c, &h);
               ^
grow.cpp:60:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             sf("%lld%lld", &a, &b);
               ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 367 ms 1400 KB Output is correct
6 Correct 391 ms 1656 KB Output is correct
7 Correct 238 ms 632 KB Output is correct
8 Correct 66 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 514 ms 1744 KB Output is correct
2 Correct 631 ms 1820 KB Output is correct
3 Correct 40 ms 384 KB Output is correct
4 Correct 85 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 1876 KB Output is correct
2 Correct 672 ms 1912 KB Output is correct
3 Correct 597 ms 512 KB Output is correct
4 Correct 448 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 1280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 1656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 2996 KB Time limit exceeded