QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671894#6693. Fast and FatSchoolbagWA 0ms3532kbC++201.7kb2024-10-24 14:54:122024-10-24 14:54:13

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 14:54:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-10-24 14:54:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vc;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef __int128_t int128;
#define rep(x, y, z) for(int x = (y); x <= (z); x++)
#define per(x, y ,z) for(int x = (y); x >= (z); x--)
#define yes cout << "YES\n"
#define no cout << "NO\n"

//#define int long long
//const int N = 1e5 + 5;
//const int mod = 1e9 + 7;
const ll inf = 1e10;

void solve(){
	int n; cin >> n;
	vector<pll> a(n + 1, {-1, -1}), b(n + 1, {-1, -1});
	ll l = inf, r = -inf; 
	rep(i, 1, n){
		cin >> a[i].first >> a[i].second; // v, w
		b[i] = a[i];
		l = min(l, a[i].first);
		r = max(r, a[i].first);
	}
	sort(a.begin() + 1, a.end(), [&](pll x, pll y){
		return x.first + x.second > y.first + y.second;
	});
	sort(b.begin() + 1, b.end(), [&](pll x, pll y){
		return x.second > y.second;
	});
	auto check = [&](ll tar) -> bool{
		vl p, q;
		rep(i, 1, n){
			if(a[i].first >= tar){
				p.push_back(a[i].first + a[i].second - tar);
			}
			if(b[i].first < tar){
				q.push_back(b[i].second);
			}
		}
		if(p.size() < q.size()) return 0;
		rep(i, 0, (int)q.size() - 1){
			if(p[i] < q[i]) return 0;
		}
		return 1;
	};
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << l << '\n';
}

signed main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int __ = 1; //cin >> __;
	while(__--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

2
5
10 5
1 102
10 100
7 4
9 50
2
1 100
10 1

output:

5

result:

wrong answer 1st numbers differ - expected: '8', found: '5'