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 AC
Exec Time 81 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All 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 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 80 ms 256 KB
b07 AC 45 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 2 ms 256 KB
b13 AC 6 ms 256 KB
b14 AC 55 ms 256 KB
b15 AC 57 ms 256 KB
b16 AC 81 ms 256 KB
b17 AC 57 ms 256 KB
b18 AC 50 ms 256 KB
b19 AC 51 ms 256 KB
b20 AC 2 ms 256 KB
b21 AC 8 ms 256 KB
b22 AC 53 ms 256 KB
b23 AC 46 ms 256 KB
b24 AC 60 ms 256 KB