summaryrefslogtreecommitdiff
path: root/sem_5/codingbattle/ex2/ex2.cpp
blob: 8ff3c080e13b1f5be4d51f9235f79ba87e659745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>
using namespace std;

int main (int argc, char ** argv){
  int g,n;
  int max=0;
  string strmax= "";
  int tmp2;
  cin >> g >> n;
  string a;
  int prixp;
  int prix;
  for (int i =0; i < n; i ++){
    cin >> a >> prixp >> prix;
    int tmp = g;
    tmp = tmp - prix;
    tmp = tmp/prixp;
    if (tmp > max){
      max=tmp;
      strmax= a;
    }
  }
  if (max == 0){
    cout << "Impossible"<<endl;
  }
  else {
    cout<<max<<endl;
    cout<<strmax;
  }
return 0;
}