提出 #67001994
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using P=pair<int,int>;
using vi=vc<int>;
void solve(){
int n;
cin>>n;
vc<int> A(n),B(n),C(n);
ll S=0,T=0;
ll c=0;
for(int i=0;i<n;i++){
cin>>A[i]>>B[i]>>C[i];
int e=min(B[i],C[i]);
S+=e;
B[i]-=e;
int f=min(A[i],B[i]);
T+=f;
A[i]-=f;
c+=min(A[i],e);
}
if(S>T){
ll d=(S-T)/2;
S-=min(c,d);
T+=min(c,d);
}
cout<<min(S,T)<<endl;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
int T;
cin>>T;
while(T--) solve();
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample-01.txt |
| All |
01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 03-01.txt, sample-01.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01-01.txt |
AC |
140 ms |
3392 KiB |
| 01-02.txt |
AC |
42 ms |
3488 KiB |
| 01-03.txt |
AC |
32 ms |
3648 KiB |
| 01-04.txt |
AC |
32 ms |
3464 KiB |
| 01-05.txt |
AC |
31 ms |
3612 KiB |
| 02-01.txt |
AC |
32 ms |
5448 KiB |
| 02-02.txt |
AC |
32 ms |
5404 KiB |
| 02-03.txt |
AC |
32 ms |
5388 KiB |
| 02-04.txt |
AC |
30 ms |
5472 KiB |
| 02-05.txt |
AC |
29 ms |
5320 KiB |
| 02-06.txt |
AC |
30 ms |
5472 KiB |
| 03-01.txt |
AC |
33 ms |
5428 KiB |
| sample-01.txt |
AC |
1 ms |
3416 KiB |