Edwardboss's blog

By Edwardboss, history, 4 years ago, In English

1629A - Скачивание оперативной памяти 借用了桶排序的思路,贪婪算法

~~~~~ ~~~~~

include<bits/stdc++.h>

using namespace std;

int main(){ cin.tie(0); ios::sync_with_stdio(false); //int x[1001]; int t,n,k,m,b; cin>>t;

while(t--){
    cin>>n>>k;
    int x[1005]={0};
    int a[n];
    for(int i=0;i<n;i++){
       cin>>m;
       a[i]=m;
    }
    for(int i=0;i<n;i++){
       cin>>b;
       x[a[i]]+=b;
    }
    for(long long i=0;i<=k and i<1005;i++){
       //cout<<x[i]<<endl;
       k+=x[i];
       x[i]=0;

    }
    cout<<k<<endl;
}
return 0;

}

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it