QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711689 | #9528. New Energy Vehicle | ucup-team1329# | Compile Error | / | / | C++20 | 1.7kb | 2024-11-05 13:01:57 | 2024-11-05 13:01:58 |
Judging History
This is the latest submission verdict.
- [2024-11-05 13:01:58]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-05 13:01:57]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
struct node
{
ll l, r, w;
};
void solve()
{
ll n, m;
cin >> n >> m;
vector<node> a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i].w >> a[i].l >> a[i].r;
sort(all1(a), [&](node a, node b)
{ return a.w > b.w; });
ll sum = 0, tot = 0;
vector<ll> f(n + 1), g(n + 1);
for (int i = 1; i <= n; i++)
{
auto [l, r, w] = a[i];
sum += l;
tot += l * w;
f[i] = (r - l) * w + f[i - 1];
g[i] = r - l + g[i - 1];
}
ll ans = tot + a[1].w * (m - sum);
// cout<<ans<<"\n";
for (int i = 2; i <= n; i++)
{
auto [l, r, w] = a[i];
ll p = tot - l * w, t = m - (sum - l);
ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1);
// cout << f[pos] + w * (m - sum + l - g[pos]) << " ";
ans = max(ans, p + f[pos] + w * (m - sum + l - g[pos]));
}
cout << ans << "\n";
}
int main()
{
IOS int T = 1;
// cin>>T;
while (T--)
solve();
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:60:21: error: no matching function for call to ‘max(long long int, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)’ 60 | ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:60:21: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 60 | ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: answer.code:60:21: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 60 | ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: answer.code:60:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 60 | ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: answer.code:60:21: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 60 | ll pos = max(1ll * i, upper_bound(all1(g), m - sum + l) - g.begin() - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~