Submission #1325977

#TimeUsernameProblemLanguageResultExecution timeMemory
1325977somefolkFestival (IOI25_festival)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long struct El { ll p, idx; }; vector<int> max_coupons(int a, vector<int> p, vector<int> t){ int n = (int)p.size(); vector<El> ones, twos; for(int i = 0; i < n; i++){ if(t[i] == 1) ones.push_back({p[i], i}); else twos.push_back({p[i], i}); } sort(ones.begin(), ones.end(), [&](auto l, auto r){ return l.p < r.p; }); sort(twos.begin(), twos.end(), [&](auto l, auto r){ return l.p < r.p; }); int osz = (int)ones.size(); vector<ll> pref1(osz); for(int i = 0; i < osz; i++){ if(i == 0) pref1[i] = ones[i].p; else pref1[i] = pref1[i-1] + ones[i].p; } auto get = [&](int cnt){ if(pref1.empty()) return 0; return (upper_bound(pref1.begin(), pref1.end(), cnt) - pref1.begin()); }; ll curr = a; int amount1 = get(curr), amount2 = 0; for(int i = 0; i < (int)twos.size(); i++){ curr = 2*(curr - twos[i].p); if(curr < 0) break; int temp = get(curr); if(temp + (i+1) > amount1 + amount2){ amount1 = temp; amount2 = (i+1); } } vector<int> sol; for(int i = 0; i < amount2; i++) sol.push_back(twos[i].idx); for(int i = 0; i < amount1; i++) sol.push_back(ones[i].idx); return sol; }

Compilation message (stderr)

festival.cpp: In lambda function:
festival.cpp:30:62: error: inconsistent types 'int' and 'long int' deduced for lambda return type
   30 |         return (upper_bound(pref1.begin(), pref1.end(), cnt) - pref1.begin());
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~