Skip to content

Instantly share code, notes, and snippets.

@MatejMecka
Created September 19, 2017 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatejMecka/81076b9c995ff4efbae628069f10bca3 to your computer and use it in GitHub Desktop.
Save MatejMecka/81076b9c995ff4efbae628069f10bca3 to your computer and use it in GitHub Desktop.
Tapa sum
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
int eggs;
int n;
vector<int> prices;
cin >> eggs;
cin >> n;
for(int i=0; i < n; i++){
int temp;
int tempt;
cin >> temp >> tempt;
int oneegg = tempt * eggs;
int tomultiply = round(eggs / 6);
int sixeggs = tomultiply * temp;
prices.push_back(sixeggs);
prices.push_back(oneegg);
}
sort(prices.begin(),prices.end());
cout << prices[0] << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment