Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <vector>
- bool IsCharLess(char a, char b) {
- return a < b;
- }
- // ABCDEFGabcdefg
- // Less
- // ab < ac
- // ab < ba
- // abb < ad
- // ab < abc
- // "" < "aa"
- // aa = aa
- bool LexCompare(const std::string& a, const std::string& b) {
- int i = 0;
- while (i < a.size() && i < b.size() && a[i] == b[i]) {
- ++i;
- }
- if (i == b.size()) return false;
- if (i == a.size()) return true;
- return IsCharLess(a[i], b[i]);
- }
- int main1() {
- int n = 0;
- std::cin >> n;
- std::vector<std::string> strings(n);
- for (int i = 0; i < n; ++i) {
- std::cin >> strings[i];
- }
- std::sort(strings.begin(), strings.end(), LexCompare);
- for (const std::string& s: strings) {
- std::cout << s << std::endl;
- }
- return 0;
- }
- struct Lesson {
- int l;
- int c;
- };
- int main() {
- int n, L;
- std::cin >> n >> L;
- std::vector<Lesson> v(n);
- for (int i = 0; i < n; ++i) {
- std::cin >> v[i].l;
- }
- for (int i = 0; i < n; ++i) {
- std::cin >> v[i].c;
- }
- std::string s = "sdfsdf";
- std::sort(v.begin(), v.end(), [&s](const Lesson& a, const Lesson& b) -> bool {
- std::cout << s << std::endl;
- return a.c > b.c;
- });
- int result = 0;
- int l = 0;
- int i = 0;
- while (i < v.size() && l + v[i].l <= L) {
- result += v[i].c * v[i].l;
- l += v[i].l;
- ++i;
- }
- if (i < v.size()) {
- result += (L - l) * v[i].c;
- }
- std::cout << result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement