Language: C++

#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct state{
	int cap;
	int have;
	int move;
};
bool operator <(const state& left, const state& right){
	return left.move > right.move;
}
int main() {
	int n;
	while (cin >> n, n){
		vector<pair<int, int>> balloon(n + 1, { 0, 0 });
		REP(i, n){
			cin >> balloon[i + 1].first >> balloon[i + 1].second;//p,t
		}
		bool clear = false;
		int ans;
		int ma = 1;
		priority_queue<state> P;//time,cap,having,move
		P.push({ 0, 0, 0, 0 });
		while (!P.empty()){
			state st = P.top(); P.pop();
			if (st.cap == n){
				P.push({balloon[st.cap].first * (st.have + 1), st.cap + 1, st.have, st.move + balloon[st.cap].first });
				continue;
			}
			if (st.cap == n + 1){
				ans = st.move;
				clear = true;
				break;
			}
			//?????£???????????????
			if (balloon[st.cap + 1].second >= balloon[st.cap].first*(st.have + 1) + balloon[st.cap + 1].first + balloon[st.cap].second)
				P.push({  st.cap + 1, 1, st.move + balloon[st.cap + 1].first + balloon[st.cap].first });

			//??????????????´???
			if (st.have <= 2)
				if (balloon[st.cap + 1].second >= abs(balloon[st.cap + 1].first - balloon[st.cap].first)*(st.have + 1) + balloon[st.cap].second)
					P.push({st.cap + 1, st.have + 1, st.move + abs(balloon[st.cap + 1].first - balloon[st.cap].first) });

			ma = max(ma, st.cap + 1);
		}
		if (clear){
			cout << "OK " << ans << endl;
		}
		else{
			cout << "NG " << ma << endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:23: error: no matching function for call to 'std::priority_queue<state>::push(<brace-enclosed initializer list>)'
   64 |                 P.push({ 0, 0, 0, 0 });
      |                 ~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<state>::value_type&' {aka 'const state&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<state>::value_type&&' {aka 'state&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:68:39: error: no matching function for call to 'std::priority_queue<state>::push(<brace-enclosed initializer list>)'
   68 |                                 P.push({balloon[st.cap].first * (st.have + 1), st.cap + 1, st.have, st.move + balloon[st.cap].first });
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<state>::value_type&' {aka 'const state&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<state>::value_type&&' {aka 'state&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~