QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#680230 | #9529. Farm Management | ucup-team3474# | WA | 1ms | 3584kb | C++23 | 1.2kb | 2024-10-26 20:18:08 | 2024-10-26 20:18:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
void solve()
{
int n ;
long long m ;
cin >> n >> m ;
vector<array<int , 3>> a(n) ;
for(int i = 0 ; i < n ; i ++)
for(int j = 0 ; j < 3 ; j ++)
cin >> a[i][j] ;
sort(a.begin() , a.end()) ;
reverse(a.begin() , a.end()) ;
long long ans = 0 ;
for(auto [w , l , r] : a)
{
m -= l ;
ans += 1ll * l * w ;
}
int L = 0 , R = n - 1 ;
while(L <= R)
{
auto& [w , l , r] = a[L] ;
int c = r - l ;
L += 1 ;
if(c == 0) continue ;
if(m > 0)
{
int t = min(m , 1ll * c) ;
ans += 1ll * t * w ;
m -= t ;
l += t ;
}
if(l == r) continue ;
if(R > L)
{
auto& [w2 , l2 , r2] = a[R] ;
int t = min(l2 , c) ;
l2 -= t ;
l += t ;
ans += 1ll * (w - w2) * t ;
if(l2 == 0) R -= 1 ;
}
}
cout << ans << '\n' ;
}
int main()
{
std::ios::sync_with_stdio(false) , cin.tie(0) ;
int T = 1 ;
while (T --) solve() ;
return 0 ;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
109
result:
ok single line: '109'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
12 62 503792 9 10 607358 1 3 600501 10 10 33249 4 4 774438 6 6 197692 3 6 495807 8 8 790225 5 9 77272 3 8 494819 4 9 894779 3 9 306279 5 6
output:
38468791
result:
wrong answer 1st lines differ - expected: '35204500', found: '38468791'