제출 #710266

#제출 시각아이디문제언어결과실행 시간메모리
710266LittleCubeCake 3 (JOI19_cake3)C++14
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast-unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;

int N, M;
ll ans = -1e18, dp[200005], v[200005], c[200005];
pii p[200005];

struct Mset
{
	vector<pair<int, ll>> op;
	multiset<ll> lms, rms;
	ll sum = 0;
	void init(int sz)
	{
		for(int i = 0; i < sz; i++)
			lms.insert(-10'000'000'000'000LL);
		sum = sz * -10'000'000'000'000LL;
	}	
	void insert(ll k)
	{
		lms.insert(k);
		op.emplace_back(pll(0, k));
		sum += k;
		rms.insert(*lms.begin());
		sum -= *lms.begin();
		op.emplace_back(pll(1, *lms.begin()));
		lms.erase(lms.begin());
	}
	void undo(int t)
	{
		while((int)op.size() > t)
		{
			auto [i, k] = op.back();
			op.pop_back();
			if(i == 0)
			{	
				lms.erase(lms.find(k));
				sum -= k;
			}
			else
			{
				rms.erase(rms.find(k));
				lms.insert(k);
				sum += k;
			}
		}
	}
}st;



// Assume (qR, L) is already in the set
void solve(int L, int R, int qL, int qR)
{
	int mid = (L + R) / 2;
	if(R < L)
		return;
	
	// cerr << L << ' ' << R << " -> " << qL << ' ' << qR << '\n'; 
	int initT = st.op.size();
	
	for (int i = mid - 1; i > qR && i >= L; i--)
		st.insert(v[i]);
	
	for (int i = min(mid - 1, qR); i >= qL; i--)
	{
		dp[i] = st.sum + v[mid] + v[i] - 2 * (c[mid] - c[i]);
		st.insert(v[i]);
	}

	st.undo(initT);

	int qMid = qL;
	for (int i = min(mid - 1, qR); i >= qL; i--)
		if(dp[i] >= dp[qMid])
			qMid = i;
	// cerr << mid << ' ' << qMid << ' ' << dp[qMid] << '\n';
	ans = max(dp[qMid], ans);

	for (int i = min(L - 1, qR); i > qMid; i--)
		st.insert(v[i]);

	solve(L, mid - 1, qL, qMid);

	st.undo(initT);

	for (int i = max(qR + 1, L); i <= mid; i++)
		st.insert(v[i]);

	solve(mid + 1, R, qMid, qR);

	st.undo(initT);
}	


signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> N >> M;
	M -= 2;
	st.init(M);
	for(int i = 1; i <= N; i++)
		cin >> p[i].S >> p[i].F;
	sort(p + 1, p + 1 + N);
	for(int i = 1; i <= N; i++)
		c[i] = p[i].F, v[i] = p[i].S;
	solve(1, N, 1, N);
	cout << ans << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

cake3.cpp:1:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
    1 | #pragma GCC optimize("Ofast-unroll-loops")
      |                                          ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cake3.cpp:2:
/usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   71 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   76 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   82 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/c++/10/cctype:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:35,
                 from cake3.cpp:2:
/usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   80 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   82 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   84 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cake3.cpp:2:
/usr/include/ctype.h:108:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  108 | __exctype (isalnum);
      | ^~~~~~~~~
/usr/include/ctype.h:108:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:109:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  109 | __exctype (isalpha);
      | ^~~~~~~~~
/usr/include/ctype.h:109:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  110 | __exctype (iscntrl);
      | ^~~~~~~~~
/usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  111 | __exctype (isdigit);
      | ^~~~~~~~~
/usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  112 | __exctype (islower);
      | ^~~~~~~~~
/usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  113 | __exctype (isgraph);
      | ^~~~~~~~~
/usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  114 | __exctype (isprint);
      | ^~~~~~~~~
/usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  115 | __exctype (ispunct);
      | ^~~~~~~~~
/usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  116 | __exctype (isspace);
      | ^~~~~~~~~
/usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  117 | __exctype (isupper);
      | ^~~~~~~~~
/usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  118 | __exctype (isxdigit);
      | ^~~~~~~~~
/usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:122:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  122 | extern int tolower (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:122:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:125:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  125 | extern int toupper (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:125:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:130:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  130 | __exctype (isblank);
      | ^~~~~~~~~
/usr/include/ctype.h:130:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:135:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  135 | extern int isctype (int __c, int __mask) __THROW;
      |                                          ^~~~~~~
/usr/include/ctype.h:135:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:142:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  142 | extern int isascii (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:142:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:146:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  146 | extern int toascii (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:146:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:150:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  150 | __exctype (_toupper);
      | ^~~~~~~~~
/usr/include/ctype.h:150:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:151:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  151 | __exctype (_tolower);
      | ^~~~~~~~~
/usr/include/ctype.h:151:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:251:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  251 | __exctype_l (isalnum_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:251:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:252:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  252 | __exctype_l (isalpha_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:252:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:253:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  253 | __exctype_l (iscntrl_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:253:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:254:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  254 | __exctype_l (isdigit_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:254:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:255:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  255 | __exctype_l (islower_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:255:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:256:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  256 | __exctype_l (isgraph_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:256:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:257:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  257 | __exctype_l (isprint_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:257:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:258:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  258 | __exctype_l (ispunct_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:258:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:259:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  259 | __exctype_l (isspace_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:259:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:260:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  260 | __exctype_l (isupper_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:260:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:261:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  261 | __exctype_l (isxdigit_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:261:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:263:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  263 | __exctype_l (isblank_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:263:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:267:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  267 | extern int __tolower_l (int __c, locale_t __l) __THROW;
      |                                                ^~~~~~~
/usr/include/ctype.h:267:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:268:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  268 | extern int tolower_l (int __c, locale_t __l) __THROW;
      |                                              ^~~~~~~
/usr/include/ctype.h:268:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:271:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  271 | extern int __toupper_l (int __c, locale_t __l) __THROW;
      |                                                ^~~~~~~
/usr/include/ctype.h:271:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:272:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  272 | extern int toupper_l (int __c, locale_t __l) __THROW;
      |                                              ^~~~~~~
/usr/include/ctype.h:272:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/errno.h:37:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   37 | extern int *__errno_location (void) __THROW __attribute_const__;
      |                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/errno.h:37:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:122:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  122 | extern char *setlocale (int __category, const char *__locale) __THROW;
      |                                                               ^~~~~~~
/usr/include/locale.h:122:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:125:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  125 | extern struct lconv *localeconv (void) __THROW;
      |                                        ^~~~~~~
/usr/include/locale.h:125:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:142:24: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  142 |       locale_t __base) __THROW;
      |                        ^~~~~~~
/usr/include/locale.h:142:24: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:176:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  176 | extern locale_t duplocale (locale_t __dataset) __THROW;
      |                                                ^~~~~~~
/usr/include/locale.h:176:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:180:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  180 | extern void freelocale (locale_t __dataset) __THROW;
      |                                             ^~~~~~~
/usr/include/locale.h:180:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:187:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  187 | extern locale_t uselocale (locale_t __dataset) __THROW;
      |                                                ^~~~~~~
/usr/include/locale.h:187:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/c++/10/cmath:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cake3.cpp:2:
/usr/include/c++/10/bits/cpp_type_traits.h:500:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  500 |     __miter_base(_Iterator __it)
      |                                ^
In file included from /usr/include/c++/10/cmath:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cake3.cpp:2:
/usr/include/c++/10/ext/type_traits.h:152:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  152 |     __is_null_pointer(_Type* __ptr)
      |                                   ^
/usr/include/c++/10/ext/type_traits.h:157:28: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  157 |     __is_null_pointer(_Type)
      |                            ^
/usr/include/c++/10/ext/type_traits.h:162:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  162 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
In file included from /usr/include/math.h:289,
                 from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cake3.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:22:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   22 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:22:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:26:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   26 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:26:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:30:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   30 | __MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                             ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:30:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:33:78: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   33 | __MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                              ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:33:78: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:36:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   36 | __MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                             ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:36:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cake3.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:39:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   39 | __MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:39:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/math.h:289,
                 from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cake3.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:43:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   43 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:43:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,