BanazadehAria's blog

By BanazadehAria, history, 5 years ago, In English

Hi,

There is no editorial for problem 734C ==> http://codeforces.com/problemset/problem/734/C

Please give me some hint.

Thanks in advance :(

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Binary search

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I am not blind I can see the tag dude :(

    Please Give more detail.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks, Where you found it?

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it
        #include<bits/stdc++.h>
        using namespace std;
        
        const int MAXN = 2*1e5+5;
        int pricefirst[MAXN],pricesecond[MAXN],firsts[MAXN],seconds[MAXN];
        const int INF = 1e9+7;
        
        bool ok(int cap,int needed){
            return (cap>=needed);
        }
        
        int main()
        {
            int n,first,second;cin >> n >> first >> second;
            int time,cap;cin >> time >> cap;
            for(int i=0;i<first;++i) cin >> firsts[i];
            for(int i=0;i<first;++i) cin >> pricefirst[i];
            for(int i=0;i<second;++i) cin >> seconds[i];
            for(int i=0;i<second;++i) cin>> pricesecond[i];
        
            // We fix the a potion from type first
        
            int mins = time*n;
        
            for(int i=0;i<first;++i){
                int capnow = cap-pricefirst[i];
                if(capnow<=0 || !ok(capnow,pricesecond[0])) continue;
                int l=0,r=second;
                while((r-l)>1){
                    int mid = l + (r-l)/2;
                    if(ok(capnow,pricesecond[mid])){
                        l=mid;
                    }else r=mid;
                }
                int res = (n-seconds[l])*firsts[i];
                mins = min(mins,res);
            }
            cout << mins;
        }
        

        rotavirus can you see what is the problem with it?? I got WA on test case 3.