提出 #67002835


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define all(x) (x).begin(), (x).end()
 
template<template<typename> class Container, typename G>
ostream& operator<<(ostream& os, Container<G> x) {
    int f = 0; os << '{'; for (auto &i: x) os << (f++ ? ", " : ""), os << i; os << "}";
    return os;
}
 
void _print() {cerr << "]\n";}
 
template<typename T, typename... V>
void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr <<", "; _print(v...);}
 
#ifdef DEBUG
#define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define dbg(x...)
#endif

#define pii pair<int, int>
#define f first
#define s second

void solve(){
	int n;cin>>n;vector<array<int,3>>a(n);for(int i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
	// bsearch on ans then we need to force some easy and some hard
	function<bool(int)> works=[&](int w){
		int easy=0,hard=0;
		// we want i total contests meaning we want i easy problems, which we will take from the contests sorted by how many easy we can take without taking away frmn the number of hard problems that is achievable
		int no_of_swap_options=0;
		for(auto i:a){
			int ha=min(i[1],i[0]);
			easy+=ha;
			if(ha<i[1]){
				int a=min(i[2],i[1]-ha);
				hard+=a;
				i[2]-=a;
				i[1]-=a;
			}
			// we are using everything in i[1]
			int x=min(i[1],i[2]);
			no_of_swap_options+=x;
		}
		if(easy>w){
			int x=min(easy-w,no_of_swap_options);
			hard+=x;
		}
		return min(easy,hard)>=w;
	};
	int ans=0;
	for(int i=60;i>=0;i--){
		if(works(ans+(1ll<<i)))ans+=(1ll<<i);
	}
	cout<<ans<<"\n";
}

int32_t main() {
	int t;cin>>t;while(t--)solve();
}

提出情報

提出日時
問題 A - CatCoder Double Contest
ユーザ justinlgl20
言語 C++ 20 (gcc 12.2)
得点 500
コード長 1732 Byte
結果 AC
実行時間 288 ms
メモリ 8060 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 288 ms 3488 KiB
01-02.txt AC 163 ms 3552 KiB
01-03.txt AC 149 ms 3536 KiB
01-04.txt AC 149 ms 3692 KiB
01-05.txt AC 181 ms 3964 KiB
02-01.txt AC 199 ms 7828 KiB
02-02.txt AC 198 ms 8060 KiB
02-03.txt AC 199 ms 8060 KiB
02-04.txt AC 153 ms 7964 KiB
02-05.txt AC 156 ms 7888 KiB
02-06.txt AC 156 ms 7960 KiB
03-01.txt AC 168 ms 7876 KiB
sample-01.txt AC 1 ms 3472 KiB