52212023-04-22 22:39:19SleepyOverlordMediánok (40 pont)cpp17Elfogadva 40/4016ms5212 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, k, s = 0;

int main()
{
	cin >> n >> k;
	int l = 1, r = n;

	while (s < k - 2)
	{
		cout << r-- << " ";
		cout << l++ << " ";
		s += 2;
	}

	int m = (l + r) / 2;
	if (k & 1)
	{
		FOR(i, 0, n - s - 1)
		{
			if (i & 1) m += i;
			else m -= i;
			cout << m << " ";
		}
	}
	else
	{
		++m;
		cout << m << " ";
		--m;
		cout << m << " ";
		if (k < n)
		{
			--m;
			cout << m << " ";
			FOR(i, 3, n - s - 1)
			{
				if (i & 1) m += i;
				else m -= i;
				cout << m << " ";
			}
		}
	}

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1876 KiB
2Elfogadva0/013ms1916 KiB
3Elfogadva1/13ms2152 KiB
4Elfogadva1/13ms2368 KiB
5Elfogadva1/13ms2588 KiB
6Elfogadva1/13ms2800 KiB
7Elfogadva1/13ms2996 KiB
8Elfogadva1/12ms3080 KiB
9Elfogadva1/12ms3092 KiB
10Elfogadva1/12ms3088 KiB
11Elfogadva1/13ms3340 KiB
12Elfogadva1/12ms3312 KiB
13Elfogadva1/13ms3560 KiB
14Elfogadva1/13ms3768 KiB
15Elfogadva1/13ms3984 KiB
16Elfogadva1/13ms4120 KiB
17Elfogadva1/13ms4104 KiB
18Elfogadva1/13ms4236 KiB
19Elfogadva1/13ms4164 KiB
20Elfogadva1/13ms4300 KiB
21Elfogadva1/114ms4388 KiB
22Elfogadva1/114ms4388 KiB
23Elfogadva1/114ms4728 KiB
24Elfogadva1/114ms4860 KiB
25Elfogadva1/114ms4944 KiB
26Elfogadva1/114ms4832 KiB
27Elfogadva1/114ms4832 KiB
28Elfogadva1/114ms4840 KiB
29Elfogadva1/114ms4972 KiB
30Elfogadva1/114ms5072 KiB
31Elfogadva1/114ms5068 KiB
32Elfogadva1/114ms5156 KiB
33Elfogadva1/114ms5160 KiB
34Elfogadva2/216ms5072 KiB
35Elfogadva1/114ms5180 KiB
36Elfogadva1/114ms5080 KiB
37Elfogadva2/214ms5092 KiB
38Elfogadva1/114ms5160 KiB
39Elfogadva1/114ms5212 KiB
40Elfogadva1/114ms5156 KiB