为了迎合即将到来的大学专业生活,我开始华丽丽地由Pascal转C++了…
写的不好,切忌吐槽
1 #include<iostream> 2 using namespace std; 3 int t,n,ut,ft,dt; 4 const int size = 100000; 5 int a[size]; 6 void get_input() 7 { 8 char tmp; 9 cin >> t >> n >> ut >> ft >> dt; 10 for (int i=0;i<n;i++){ 11 cin >> tmp; 12 switch (tmp){ 13 case 'u': 14 a[i] = ut + dt; 15 break; 16 case 'f': 17 a[i] = ft * 2; 18 break; 19 case 'd': 20 a[i] = dt + ut; 21 break; 22 } 23 } 24 } 25 int get_answer() 26 { 27 int prel=0 ,i=0; 28 while (prel<=t) prel += a[i++]; 29 return --i; 30 } 31 int main() 32 { 33 get_input(); 34 cout << get_answer() << '\n'; 35 return 0; 36 }