提出 #67002065


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

const char nl = '\n';
const char sp = ' ';
using u64 = unsigned long long;
using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using si = unordered_set<int>;
using sl = unordered_set<ll>;
using tsi = set<int>;
using tsl = set<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using tmii = map<int, int>;
using tmll = map<ll, ll>;
using mii = unordered_map<int, int>;
using mll = unordered_map<ll, ll>;
using pqi = priority_queue<int>;
using pqig = priority_queue<int, vi, greater<int>>;
using pql = priority_queue<ll>;
using pqlg = priority_queue<ll, vl, greater<ll>>;
using pqpii = priority_queue<pii>;
using pqpll = priority_queue<pll>;

#define tp3(T) tuple<T,T,T>
#define tp4(T) tuple<T,T,T,T>

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sort_and_unique(a) sort(all(a));(a).resize(unique(all(a))-(a).begin())
#define outrange(x,min,max) ((x)<(min) || (x)>(max))

ll _start_time;
#define nano (chrono::system_clock::now().time_since_epoch().count())
#define reset_timer _start_time=nano
#define chime cout<<((nano-_start_time)/1e9)<<endl
#define init_rng mt19937_64 rng(nano ^ 19980731)
#define randint(a,b) ((a)+rng()%((b)-(a)+1))

#ifndef ONLINE_JUDGE
#define debug(x) (cout<<(#x)<<':'<<(x)<<'\n')
#else
#define debug(x)
#endif

void yesno(bool a) {
	cout << (a ? "Yes\n" : "No\n");
}

template<typename L, typename R>
ostream& operator<<(ostream& out, const pair<L, R>& p) {
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template<typename T1, typename T2, typename T3>
ostream& operator<<(ostream& out, const tuple<T1, T2, T3>& tp) {
	auto &[t1, t2, t3] = tp;
	out << '(' << t1 << ',' << t2 << ',' << t3 << ')';
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	for (auto &i : v) out << i << ' ';
	out << nl;
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& v) {
	for (auto &i : v) out << i << ' ';
	out << nl;
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const unordered_set<T>& v) {
	for (auto &i : v) out << i << ' ';
	out << nl;
	return out;
}

template<typename K, typename V>
ostream& operator<<(ostream& out, const map<K, V>& m) {
	out << '[';
	for (auto &[k, v] : m) {
		out << k << ':' << v << sp;
	}
	out << "]\n";
	return out;
}

template<typename K, typename V>
ostream& operator<<(ostream& out, const unordered_map<K, V>& m) {
	out << '[';
	for (auto &[k, v] : m) {
		out << k << ':' << v << sp;
	}
	out << "]\n";
	return out;
}

void set_min(auto& x1,auto x2){
	x1=min(x1,x2);
}

void set_max(auto& x1,auto x2){
	x1=max(x1,x2);
}

const int MAX=200005;
ll a[MAX];
ll b[MAX];
ll c[MAX];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _t;
	cin>>_t;
	while(_t--){
		int n;
		cin>>n;
		ll total=0;
		ll A_min=0;
		ll A_max=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i]>>c[i];
			set_min(b[i], a[i]+c[i]);
			total+=b[i];
			A_min+=max(0LL, b[i]-c[i]);
			A_max+=min(b[i], a[i]);
		}
		ll ans;
		if(A_min>=(total+1)/2) ans=total-A_min;
		else if(A_max<=total/2) ans=A_max;
		else ans=total/2;
		cout<<ans<<nl;
	}
}

提出情報

提出日時
問題 A - CatCoder Double Contest
ユーザ YocyCraft
言語 C++ 20 (gcc 12.2)
得点 500
コード長 3498 Byte
結果 AC
実行時間 39 ms
メモリ 8164 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 1
AC × 13
セット名 テストケース
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 39 ms 3536 KiB
01-02.txt AC 32 ms 3480 KiB
01-03.txt AC 30 ms 3424 KiB
01-04.txt AC 30 ms 3520 KiB
01-05.txt AC 30 ms 3960 KiB
02-01.txt AC 31 ms 8152 KiB
02-02.txt AC 33 ms 8080 KiB
02-03.txt AC 32 ms 8128 KiB
02-04.txt AC 29 ms 8164 KiB
02-05.txt AC 29 ms 8116 KiB
02-06.txt AC 29 ms 8108 KiB
03-01.txt AC 33 ms 8080 KiB
sample-01.txt AC 1 ms 3476 KiB