Submission #2955127


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second
vector<pair<int,pair<int,int> > > v;
int  main(){
int d,g;
cin>>d>>g;
for(int i=0;i<d;i++)
{
    int a,b;
    cin>>a>>b;int o=(i+1)*100;
    v.push_back(make_pair(o ,make_pair(a,b)));
}int o=1e8;
do{
   int p=g,k=0;
   for(int i=0;i<d;i++)
   {if(p<=0)
   break;
       if(v[i].ff*v[i].ss.ff+v[i].ss.ss<=p)
       {
           p-=v[i].ff*v[i].ss.ff+v[i].ss.ss;
           k+=v[i].ss.ff;
       }
           else if(v[i].ff*v[i].ss.ff+v[i].ss.ss>=p&&v[i].ff*v[i].ss.ff<p)
       {
           p-=v[i].ff*v[i].ss.ff+v[i].ss.ss;
           k+=v[i].ss.ff;
       }
       else {
        k+=p/v[i].ff;
        if(p%v[i].ff!=0)
            k++;
        p=0;
       }
   }
   o=min(o,k);
}
while(std::next_permutation(v.begin(), v.end()));
cout<<o;
}

Submission Info

Submission Time
Task C - All Green
User titanium
Language C++14 (GCC 5.4.1)
Score 300
Code Size 889 Byte
Status
Exec Time 81 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03, a04
All 300 / 300 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 1 ms 256 KB
a02 1 ms 256 KB
a03 1 ms 256 KB
a04 1 ms 256 KB
b05 1 ms 256 KB
b06 80 ms 256 KB
b07 45 ms 256 KB
b08 1 ms 256 KB
b09 1 ms 256 KB
b10 1 ms 256 KB
b11 1 ms 256 KB
b12 2 ms 256 KB
b13 6 ms 256 KB
b14 55 ms 256 KB
b15 57 ms 256 KB
b16 81 ms 256 KB
b17 57 ms 256 KB
b18 50 ms 256 KB
b19 51 ms 256 KB
b20 2 ms 256 KB
b21 8 ms 256 KB
b22 53 ms 256 KB
b23 46 ms 256 KB
b24 60 ms 256 KB