50542023-04-12 14:00:12czitaBányász RPG (40 pont)cpp17Wrong answer 0/4068ms5984 KiB
// banyaszrpg.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
	vector<pair<int,int>> T;
	
	int a;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a;
		T.push_back(make_pair(a, 0));
	}
	for (size_t i = 0; i < n; i++)
	{
		cin >> a;
		T[i].second = a;
	}
	sort(T.begin(), T.end());
	long ido = 0, tp = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (T[i].first>tp)//nincs elég tp
		{
			
			if (T[i].first-tp>T[i].second)
			{
				ido += (T[i].second) * 2;
			}
			else
			{
				ido += (T[i].second-T[i].first+tp+1) * 2+T[i].second-T[i].first;
			}
			tp += T[i].second;
		}
		else
		{
			ido += T[i].second;
			tp += T[i].second;
		}
	}
	cout << ido;
	
}

SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/03ms1720 KiB
2Wrong answer0/014ms2380 KiB
3Wrong answer0/23ms2060 KiB
4Wrong answer0/23ms2264 KiB
5Wrong answer0/212ms2888 KiB
6Wrong answer0/223ms3160 KiB
7Wrong answer0/24ms2860 KiB
8Wrong answer0/26ms2860 KiB
9Wrong answer0/33ms2904 KiB
10Wrong answer0/33ms3116 KiB
11Wrong answer0/33ms3332 KiB
12Wrong answer0/33ms3416 KiB
13Wrong answer0/43ms3424 KiB
14Wrong answer0/43ms3432 KiB
15Wrong answer0/239ms4776 KiB
16Wrong answer0/252ms5660 KiB
17Wrong answer0/243ms4948 KiB
18Wrong answer0/268ms5984 KiB