Submission #926396

# Submission time Handle Problem Language Result Execution time Memory
926396 2024-02-12T21:41:04 Z midi A Plus B (IOI23_aplusb) C++17
10 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define vc vector
typedef vc<ll> vcll;
typedef vc<bool> vcb;
#define pr pair
typedef pr<ll, ll> prll;
typedef map<ll,ll> mapll;
typedef unordered_map<ll,ll> umapll;

#define f0r(i,a,n) for ((i)=(a); (i)<=(n); (i)++)
#define r0f(i,n,a) for ((i)=(n); (i)>=(a); (i)--)

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define fi first
#define se second
#define sz size
#define all(x) (x).begin(), (x).end()
#define all0(x, n) (x).begin(), (x).begin()+n
#define all1(x, n) (x).begin()+1, (x).begin()+n+1
#define allrev(x) (x).rbegin(), (x).rend()
#define in(v, s) ((s).find((v)) != (s).end())
#define GCD(x, y) __gcd(abs((x)), abs((y)))

#define INF (LLONG_MAX>>3ll)
#define MOD 1'000'000'007ll

#define mxN 100'010ll

inline void maxa(ll &a, ll b) { if (a<b) a=b; }
inline void mina(ll &a, ll b) { if (a>b) a=b; }

ll n;
vc<int> ans;
int ar[mxN], bar[mxN];

struct pnt { ll i, j; };
inline pnt mpnt (ll i, ll j)
{
	pnt ans;
	ans.i=i, ans.j=j;
	return ans;
}
inline ll s (pnt a) { return ar[a.i] + bar[a.j]; }
inline bool operator< (const pnt &a, const pnt &b) { return s(a) > s(b); }

vc<int> smallest_sums(int N, vc<int> A, vc<int> B)
{
	n=N;
	sort(all0(A, n));
	sort(all0(B, n));
	ll i, j;
	f0r(i,1,n) ar[i]=A[i-1], bar[i]=B[i-1];
	ll cnt=0;

	priority_queue<pnt> pq;
	pq.push(mpnt(1,1));

	f0r(cnt,1,n)
	{
		pnt ij = pq.top(); pq.pop();
		ans.pb(s(ij));
		i=ij.i, j=ij.j;
		if (i!=n) pq.push(mpnt(i+1, j));
		if (j!=n) pq.push(mpnt(i, j+1));
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 6th token, expected: '32', found: '31'
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 6th token, expected: '32', found: '31'
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 6th token, expected: '32', found: '31'
8 Halted 0 ms 0 KB -