48812023-04-05 22:05:12SleepyOverlordBányász RPG (40 pont)cpp17Hibás válasz 24/4067ms4712 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

int n;
VPII a;

int main()
{
	cin >> n;
	a.RS(n + 1);

	FOR(i, 1, n) cin >> a[i].X;
	FOR(i, 1, n) cin >> a[i].Y;

	sort(a.BG + 1, a.EN);
	ULL experience = 0, time = 0;
	FOR(i, 1, n) 
	{
		if (a[i].X > experience) 
			if (experience + a[i].Y <= a[i].X) time += a[i].Y * 2;
			else time += (a[i].X - experience) * 2 + a[i].Y - a[i].X;
		else time += a[i].Y;
		experience += a[i].Y;
	}

	cout << time;

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base24/40
1Elfogadva0/03ms1880 KiB
2Elfogadva0/014ms2320 KiB
3Elfogadva2/23ms2276 KiB
4Elfogadva2/23ms2368 KiB
5Hibás válasz0/212ms2720 KiB
6Hibás válasz0/223ms3068 KiB
7Hibás válasz0/24ms2956 KiB
8Hibás válasz0/26ms2896 KiB
9Elfogadva3/33ms2988 KiB
10Elfogadva3/33ms3200 KiB
11Elfogadva3/33ms3408 KiB
12Elfogadva3/33ms3504 KiB
13Elfogadva4/43ms3604 KiB
14Elfogadva4/43ms3496 KiB
15Hibás válasz0/239ms4192 KiB
16Hibás válasz0/250ms4324 KiB
17Hibás válasz0/243ms4192 KiB
18Hibás válasz0/267ms4712 KiB