50532023-04-12 13:54:41czitaBányász RPG (40 pont)cpp11Wrong answer 0/4068ms6232 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());
	int 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/03ms1808 KiB
2Wrong answer0/014ms2420 KiB
3Wrong answer0/23ms2212 KiB
4Wrong answer0/23ms2440 KiB
5Wrong answer0/212ms3080 KiB
6Wrong answer0/223ms3488 KiB
7Wrong answer0/24ms2992 KiB
8Wrong answer0/26ms3352 KiB
9Wrong answer0/33ms3276 KiB
10Wrong answer0/33ms3524 KiB
11Wrong answer0/33ms3700 KiB
12Wrong answer0/33ms3792 KiB
13Wrong answer0/43ms3924 KiB
14Wrong answer0/43ms4140 KiB
15Wrong answer0/239ms5252 KiB
16Wrong answer0/252ms6232 KiB
17Wrong answer0/243ms5476 KiB
18Wrong answer0/268ms6228 KiB