id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n priority_queue<pair<double,int>>pq;\n int n=health.size();\n long long sum=0;\n for(int i=0;i<n;i++){\n int time=(health[i]/power)+(health[i]%power==0?0:1);\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n bool static cmp(pair<double,int>& p, pair<double,int>& p1){\n return p.first > p1.first;\n }\n\n long long minDamage(int p, vector<int>& d, vector<int>& h) {\n vector<pair<double,int>> vp;\n int n=d.size();\n for(int i=0;i<n;i++){\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<int,int>> vp;\n long long sum=0;\n int n=damage.size();\n for(int i=0;i<n;i++){\n int time=(health[i]/power);\n if(health[i]%power){\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<double,int>>en;\n int n=damage.size();\n for(int i=0;i<n;i++){\n health[i]=(health[i]+power-1)/power;\n double ratio=((1.00)*damage[i]/(1.00*health[i]));... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n static bool comparator(tuple<int, double, int> a, tuple<int, double, int>b) {\n if(get<1>(a) == get<1>(b)) return get<2>(a) < get<2>(b);\n\n return get<1>(a) > get<1>(b);\n }\n\n long long find_total(vector<int>& arr) {\n long long res = 0;\n\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "#include<bits/stdc++.h>\nbool customComparison(pair<long long, long long> a, pair<long long, long long> b){\n return (((double) (a.second) / (double) (a.first)) > ((double) (b.second) / (double) (b.first))); \n } \nclass Solution {\npublic:\n \n \n long long minDamage(int power, vector<i... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long res = 0, sum = 0;\n priority_queue<pair<double, int>> pq;\n for(int i = 0; i < damage.size(); ++i){\n int time = health[i]/power + ((health[i]%power)?1:0);\n pq.push(... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 2 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long minDamage(int k, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n\n ll sum = accumulate(damage.begin(), damage.end(), 0LL);\n\n vector<pair<ll,ll>> v;\n for(int i = 0; i<n;i++){\n hea... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<double,pair<int,int>>>v; int total=0;\n long long ans=0;\n for(int i=0;i<damage.size();i++){\n total+=damage[i];\n int shots=ceil((double)health[i]/(double)powe... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = health.size();\n long long sum = 0, ans = 0;\n for (int i = 0; i < n; i++) {\n if (health[i] % power == 0) health[i] /= power;\n else {\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n static bool comp(const pair <long double, pair <int, int>> &a, const pair <long double, pair <int, int>> &b) {\n return a.first > b.first;\n }\n\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<int> timeToKill;\n for(int i = 0; i < health.size(); i++) {\n if(health[i] < power) {\n timeToKill.push_back(1);\n } else if(health[i] > powe... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "bool cmp(pair<long long int,long long int>&a,pair<long long int,long long int>&b){\n return (((long double)a.first/(long double)a.second)>((long double)b.first/(long double)b.second));\n }\nclass Solution {\npublic:\n long long int f(long long int a,int p){\n if(a%p==0){\n re... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n\n static bool compare(pair<int,long long> a, pair<int,long long> b){\n return ( (1LL*b.first*a.second) < (1LL*a.first*b.second) );\n }\n \n int ceiling(int a, int b){\n int c=a/b;\n if((b*c)==a) return c;\n else return c+1;\n }\n\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\nstatic bool comp(pair<long long int, long long int>&a, pair<long long int,long long int> &b){\n double x = (double)a.first/(double)a.second;\n double y = (double)b.first/(double)b.second;\n return x>y;\n}\n long long minDamage(int power, vector<int>& damage, vector<in... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n using ii = pair<int,int>;\n #define F first \n #define S second\n long long minDamage(int power, vector<int>& d, vector<int>& h) {\n int n = d.size();\n vector<int> t(n);\n for(int i=0;i<n;i++){\n t[i] = (h[i]+power-1)/power;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& d, vector<int>& h) {\n int n=d.size();\n vector<int>vdiv;\n vector<pair<double,int>>vc;\n ll sum=0;\n for(int i=0;i<n;i++){\n int curr=(h[i]+power-1)/power;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n\n static bool sortbyCond(const pair<double,pair<int, int>>& a, pair<double,pair<int, int>>& b)\n {\n return a.first>b.first;\n }\n\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n \n vector<int>at;\n int n = d... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n int n = damage.size();\n long long sum = 0;\n vector<int> hits;\n vector<pair<double, int>> damageRate;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int p, vector<int>& dmg, vector<int>& hp) {\n using LL = long long;\n LL res = 0;\n int n = dmg.size();\n LL dmgSum = 0;\n vector<int> F;\n vector<float> R;\n vector<tuple<float, float, int>> v;\n \n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n\n vector<long long> time(n);\n for (int i = 0; i < n; i++)\n time[i] = (health[i] + power - 1)/power;\n \n vector<pair<double, i... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<int> count(n, 0);\n for(int i = 0; i < n; i++) {\n count[i] = health[i] / power;\n if(health[i] % power != 0) count[i]++;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<int>killTime;\n for( int i=0; i < n; i++ ){\n int t = health[i]/power;\n if( health[i]%power != 0 ) t+=1;\n killT... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "typedef long long int ll;\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n ll n = damage.size();\n ll total = 0;\n vector<pair<ll, ll>> v;\n vector<int> time;\n for(auto it: health){\n int val = (it % ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n priority_queue<pair<double, int>> pq;\n int n = damage.size();\n long long s = 0;\n vector<int> time;\n for (int i=0; i<n; i++) {\n s += damage[i];\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n static bool mycomp(pair<double,int> &a, pair<double,int> &b)\n {\n return a.first > b.first;\n }\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long sum = accumulate(damage.begin(),damage.end(),0);\n vector <p... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n priority_queue<tuple<double,long long,long long>>pq;\n long long tsum=0;\n for(int i=0;i<damage.size();i++){\n long long val=ceil((health[i])/(double)power);\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n=health.size();\n\n for(int i=0;i<n;i++){\n int a=health[i]/power;\n if(health[i]%power)a++;\n health[i]=a;\n }\n\n // for(auto it:he... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = health.size();\n vector<int> time(n, 0);\n \n for(int i=0; i<n; i++)\n {\n time[i] = (health[i] + power - 1) / power;\n }\n \n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n=health.size();\n vector<int>time(n,0);\n priority_queue<pair<double,int>> pq;\n\n for(int i=0;i<n;i++){\n time[i]+= health[i]%power==0?(health[i]/power):(... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<double,pair<long long,long long>>>v;\n double p=power;\n long long sum=0;\n for(int i=0;i<health.size();i++)\n {\n sum+=damage[i];\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) \n {\n long res = 0;\n long d_sum = accumulate(damage.begin(), damage.end(), 0L);\n vector<array<double, 3>> pq;\n \n for(int i = 0 ; i < damage.size() ; i++)\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n auto compare = [](pair<ll,ll>&a,pair<ll,ll>&b){\n double x = (double)a.first/a.second;\n double y = (double)b.first/b.second;\n\n return ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n using ll=long long;\n using pp=pair<double,int>;\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pp> res;\n vector<ll> time;\n\n for(int i=0;i<damage.size();i++){\n time.push_back(ceil(health[i]/(doub... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<long long> tr;\n for(int i = 0; i < health.size(); i++){\n tr.push_back(ceil(static_cast<double>(health[i]) / power));\n }\n vector<pair<double, long lon... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int pow, vector<int>& dam, vector<int>& hea) \n {\n\n vector<long long >ht;\n\n\n for(auto h:hea)\n {\n ht.push_back((h+pow-1)/pow);\n\n }\n\n vector<pair<double ,int>>s;\n\n long long sum=0;\n\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<double,pair<long long,long long>>> prr;\n int n=damage.size();\n for(int i=0;i<n;i++){\n long long time=(health[i]+power-1)/power;\n double rati... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#ifndef lowbit\n#define lowbit(x) (x & (-x))\n#endif\n#define ll long long\n#define pii pair<int, int>\n#define pll pair<ll, ll>\n#define pb push_back\n#define F first\n#define S second\n#define all(_obj) _obj.begin(), _obj.end()\n#define vi vector<int>\n#define vvi vector<vector<int>>\n#define vll vector<... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<vector<int>> arr(n);\n for(int i=0; i<n; ++i) {\n arr[i] = {damage[i], health[i], power};\n }\n sort(begin(arr), end(arr)... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = health.size();\n vector<vector<int>>temp(n,vector<int>(2));\n\n for(int i = 0; i < n; i++){\n int time;\n if(health[i]%power==0) time= health[i]/pow... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& access) {\n long long n = access.size();\n long long tot_sum = 0;\n vector<int>v(n);\n for(long long i=0;i<n;i++){\n long long temp;\n if(access[i]%power==0){\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long n = health.size();\n long long sum = 0;\n vector<int> steps(n);\n for(long long i=0;i<n;i++){\n long long temp;\n if(health[i]%power==0){\n... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#include <vector>\n#include <algorithm>\n#include <numeric>\n#include <map>\n#include <cmath>\n\nusing namespace std;\n\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n multimap<double, pair<int, int>, greater<>> mp;\n int n = damage... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int sum = 0;\n for(auto it : damage) sum += it;\n vector<pair<int, int>> arr;\n for(int i = 0; i < health.size(); i++){\n int temp = health[i]/power;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n\n int checkceil(int x , int y){\n if(x%y == 0){\n return x/y;\n }\n else{\n return (x/y)+1;\n }\n }\n\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<int> hits;\n long ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "\n#define ll long long int\n\nclass Solution {\npublic:\n \n ll minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n ll ans = 0;\n ll sum = 0;\n vector<double> arr(n);\n for(int i=0; i<n; i++) {\n arr[i] = double(dam... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n #define ll long long\n long long minDamage(int p, vector<int>& d, vector<int>& h) {\n \n int n =d.size();\n vector<ll>time(n);\n for(int i =0;i<n;i++){\n time[i]=ceil((1.0*h[i])/(1.0*p));\n }\n vector<pair... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& dam, vector<int>& h) {\n long long td = accumulate(dam.begin(),dam.end(),0LL);\n set<pair<double,int>> s; int n= h.size();\n for(int i = 0;i<n;i++){\n int time_to_kill = (h[i]+power-1)/power;\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int len = damage.size();\n vector<int> secs(len, 0);\n multimap<double, int> pq; // d1/sec1, index\n for (int i=0; i<len; i++) {\n secs[i] = ceil((double)health... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#define ll long long\n#define X first\n#define Y second\nclass Solution {\npublic:\n static bool custom(const pair<int,int>& p1,const pair<int,int>& p2){\n if(p1.X!=p2.X){\n return p1.X*p1.Y<p2.X*p2.Y;\n }\n else{\n return p1.Y<p2.Y;\n }\n }\n long... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n typedef pair<double,pair<int,int>>p;\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<int>t;\n int n = damage.size();\n\n for (int i=0; i<n; i++){\n t.push_back((health[i]+power-1)/power);\n }\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Enemy{\npublic:\n long long damage;\n long long health;\n long long power;\n double ratio;\n\n Enemy(long long _damage, long long _health, long long _power) {\n damage = _damage;\n health = _health;\n power = _power;\n ratio = (double)damage / (double)health... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<int> rounds(n, 0);\n for (int i = 0; i < n; i++) {\n // Calculate the number of rounds needed to defeat each enemy\n rounds[... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n int i=0;\n static bool comp(vector<long long> &a, vector<long long> &b){\n int power=a[2];\n // cout<<\" comp \"<<a[0]<<\" \"<<b[0]<<endl;\n double s1 = ceil((float)a[1]/(float)power);\n double s2 = ceil((float)b[1]/(float)power);\n // co... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "\nclass Solution {\npublic:\n \n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long sum=0;\n int n=damage.size();\n long long ans=0;\n // {damage per second,i}\n vector<pair<long double,int>> vp;\n for(int i=0;i<n;i++){\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "typedef long long ll;\n\nclass Solution {\npublic:\n long long minDamage(int p, vector<int>& d, vector<int>& h) {\n \n int n = d.size();\n vector<pair<long double, int>> a;\n \n ll sum = 0;\n \n for(int i = 0; i<n; i++)\n {\n ll time = c... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n \n vector<pair<double, int>> enemies;\n // 計算每個敵人的危險度(每秒傷害/擊敗時間)\n for (int i = 0; i < n; i++) {\n int time = (health[i] + power... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long ans=0;\n int n = damage.size();\n long long sum =0;\n for(int i=0; i <n; i++){\n sum += damage[i];\n } \n vector<pair<double,int>> vp;... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, std::vector<int>& damage, std::vector<int>& health) {\n std::vector<int> time;\n int n = damage.size();\n \n for (int i = 0; i < n; i++) {\n time.push_back(ceil(health[i] * 1.0 / power));\n }\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<int> samay;\n for(int i=0;i<n;i++){\n samay.push_back(ceil(health[i]*1.0/power));\n }\n multimap<double,int> destination;... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\n #define ll long long\n ll p;\n static bool cmp(const pair<pair<ll,ll>,pair<ll,ll>> &a,const pair<pair<ll,ll>,pair<ll,ll>> &b){\n ll sum = a.first.first + b.first.first;\n ll p1 = a.first.second;\n ll t1 = (a.second.first+p1-1)/p1;\n ll t2 = (b.second... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#include <vector>\n#include <algorithm>\n#include <set>\n\nusing namespace std;\n\nclass DSU {\nprivate:\n vector<int> parent;\n vector<int> size;\n\npublic:\n DSU(int n) {\n parent.resize(n);\n size.resize(n, 1); \n for (int i = 0; i < n; ++i) {\n parent[i] = i; \... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n\n typedef long long ll;\n typedef long double ld;\n\n static bool comp(const pair<ll, ll>& p1, const pair<ll, ll>& p2) {\n if (p1.first != p2.first)\n return p1.first > p2.first; // Sort by damage descending\n return p1.second < p2.second; // ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n //total damage from enemy[i] = tAlive * damage[i]\n //time to kill enemey[i] = power / health[i]\n //damage = sum(tAlive * damage[i]) -> (power/health[i]) * damage[i]\n //... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "#define ll long long\n#define fi first \n#define se second\n#define ld long double\n\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long p = power, n = health.size();\n vector<ll> t(n);\n for(int i=0; i<n; ++i) t[i] = (... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "using ll = long long;\nusing vi = vector<int>;\nusing vll = vector<ll>;\nusing vb = vector<bool>;\nusing pi = pair<int, int>;\nusing pll = pair<ll, ll>;\n\n#define fi first\n#define se second\n#define pb push_back\n#define all(x) x.begin(), x.end()\n#define rall(x) x.rbegin(), x.rend()\n\nclass Solution {\... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n // vector<pair<int,int>> temp;\n // for(int i=0;i<damage.size();i++){\n // temp.push_back(make_pair(damage[i],health[i]));\n // }\n map<double,vector<int>> mp;\... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<long long> time(n);\n vector<pair<long double, int>> v;\n\n for(int i = 0; i < n; i++)\n {\n time[i] = 1LL*ceil((1.0*heal... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\nlong long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size(); // Number of enemies\n int total_damage = 0; // Total damage taken by Bob\n\n // Create a vector of pairs (damage, health)\n vector<long long> time(n);\n for(int ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n priority_queue<pair<int,int>>pq;\n int n=damage.size();\n vector<pair<int,int>>vp(n);\n long long sum=0;\n long long tot=0;\n vector<pair<long double,pair<in... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n \n long long ans = 0;\n\n vector<pair<long double, int>> dps;\n vector<int> time;\n for(int i = 0; i<n; i++){\n int t = (... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\n // bool comparefn(pair<int,int>& a,pair<int,int>& b){\n // if(a.first==b.first) return (b.second>a.second);\n\n // return (a.first > b.first);\n // }\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long total = ac... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n \n map<double, vector<int>> mp;\n int n = damage.size();\n int total = 0;\n \n for(int i=0; i<n; i++){\n int times = (health[i] + power-1)/power;\... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<int> cycles;\n long long totc = 0;\n for (int h : health) {\n int c = h/power;\n if (h%power != 0) c++;\n cycles.push_back(c);\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) \n {\n vector<int>he;\n for(auto x:health)\n {\n if(x%power==0)\n he.push_back(x/power);\n else\n he.push_back((x/power)+1);\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n \n static bool comp(vector<long double> &a, vector<long double> &b){\n if(a[0]==b[0]){\n if(a[1]==b[1]) return a[2]>b[2];\n return a[1]<b[1];\n }\n return a[0]<b[0];\n }\n \n long long minDamage(int power, vector<int>& da... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n long long totalDamage = 0;\n long long ans = 0;\n priority_queue<pair<long double, int>> pq;\n vector<long double> times(n);\n for (... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "\n bool sortbysec(const vector<int> &a,\n const vector<int> &b)\n {\n return (a[0]*a[1] + b[0]*(a[1] + b[1]) < a[0]*(a[1] + b[1]) + b[0] *b[1]);\n }\nclass Solution {\n \npublic:\n\n \n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "using namespace std;\n\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<long double, int>> v;\n vector<int> t;\n int n = damage.size();\n long long ans = 0;\n for (int i = 0; i < n; i++) {\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "using namespace std;\n\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n vector<pair<long double, int>> v;\n vector<int> t;\n int n = damage.size();\n long long ans = 0;\n for (int i = 0; i < n; i++) {\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n static bool comp(vector<int> &a, vector<int> &b){\n return (double)a[1]/((a[2]+a[3]-1)/a[3]) < (double)b[1]/((b[2]+b[3]-1)/b[3]);\n }\n\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n=damage.size();\n vector<vect... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n=damage.size();\n vector<vector<int>> v;\n for (int i=0; i<n; ++i) {\n v.push_back({damage[i],health[i]});\n } \n sort(v.begin(),v.end(),[&](auto& a... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n priority_queue<pair<double, pair<long long, long long>>, vector<pair<double, pair<long long, long long>>>, greater<pair<double, pair<long long, long long>>>> pq;\n vector<long long> noO... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& d, vector<int>& h) \n {\n int n = d.size();\n vector<long long> time;\n vector<pair<long double, int>> DPS;\n long long sum = 0, ans = 0;\n\n for(int i=0; i<n; ++i)\n {\n time.... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long n = health.size();\n vector<long long> time;\n vector<pair<long double, int>> arr;\n for (int i = 0; i < n; i++) {\n time.push_back(1LL * ceil((1.0 * ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long n = health.size();\n vector<long long> time;\n vector<pair<long double,int>> arr; \n \n for(int i=0;i<n;i++){\n time.push_back(1LL*ceil((1.0*he... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n long long n = health.size();\n vector<long long> time;\n vector<pair<long double,int>> arr; \n \n for(int i=0;i<n;i++){\n time.push_back(1LL*ceil((1.0*he... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n map<double,vector<pair<int,int>>> mp;\n int n = health.size();\n int sum = 0;\n for(int i=0;i<n;i++){\n health[i] = (health[i] + power - 1) / power;\n\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n map<double,vector<pair<int,int>>> mp;\n int n = health.size();\n int sum = 0;\n for(int i=0;i<n;i++){\n health[i] = (health[i] + power - 1) / power;\n\n ... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "typedef long long int ll;\nclass Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<int> timeToDie(n, 0);\n\n for (int i = 0; i < n; i++) {\n timeToDie[i] = ceil((double)health[i] / (double)po... |
3,531 | <p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>al... | 3 | {
"code": "class Solution {\npublic:\n long long minDamage(int power, vector<int>& damage, vector<int>& health) {\n int n = damage.size();\n vector<long long>timeReq(n);\n vector<long double>damagePerSecond(n);\n long long sum = 0;\n for(int i=0;i<n;i++){\n sum+=damage... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string &a, string &b) {\n return (a[0] + a[1]) % 2 == (b[0] + b[1]) % 2;\n }\n};",
"memory": "7500"
} |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool also_check(int a, int b) {\n if ( a % 2 == 0) {\n return b % 2 == 0;\n }\n else {\n return b % 2 == 1;\n }\n }\n\n bool check(char c1, char c2, char d1, char d2) {\n int i1 = c1 - 'a';\n int i2 = c2 - '1';\n int j1 = d1 - 'a';\n int j2 =... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n int a=coordinate1[0]-'a';\n int b=coordinate1[1]-'1';\n int c=coordinate2[0]-'a';\n int d=coordinate2[1]-'1';\n return (a+b)%2 == (c+d)%2 ;\n }\n};",
"memory": "7700"
... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string c1, string c2) {\n int a = c1[0] - 'a', b = c1[1] - '1';\n int c = c2[0] - 'a', d = c2[1] - '1';\n return !(((a+b) & 1) ^ ((c + d) & 1));\n }\n};",
"memory": "7700"
} |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n int res1 = coordinate1[0] + coordinate1[1];\n int res2 = coordinate2[0] + coordinate2[1]; \n return res1 % 2 == res2 % 2; \n }\n};",
"memory": "7800"
} |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n \n cout << 'c'- 0 - 96;\n int v1 = coordinate1[0] - 0 - 96;\n int v2 = coordinate2[0] - 0 - 96;\n int ans1 = v1 + (coordinate1[1] - '0');\n int ans2 = v2 + (coordina... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n int c1=(coordinate1[0]-'a')+(coordinate1[1]-'0');\n int c2=(coordinate2[0]-'a')+(coordinate2[1]-'0');\n if((c1+c2)%2){\n return false;\n }\n return true;\n }\... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 0 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n int col1 = coordinate1[0] - 'a'; // calculate the column index for coordinate1\n int row1 = coordinate1[1] - '1'; // calculate the row index for coordinate1\n int col2 = coordinate2[0] -... |
3,553 | <p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png"... | 2 | {
"code": "class Solution {\npublic:\n bool checkTwoChessboards(string coordinate1, string coordinate2) {\n int res1 = coordinate1[0] + coordinate1[1];\n int res2 = coordinate2[0] + coordinate2[1]; \n return res1 % 2 == res2 % 2; \n }\n};",
"memory": "8000"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.