Submission #1318093

#TimeUsernameProblemLanguageResultExecution timeMemory
1318093marzuq01Art Exhibition (JOI18_art)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define nl '\n'
#define debug(x) cout << #x << ": " << x << "\n";
const int mod = 1e9+7;
const int MOD = 998244353;

string yes = "YES";
string no = "NO";

// CODING SETTING :O

void freo(string name) {
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
void fastIO() {
	ios::sync_with_stdio(0);
	cin.tie(0);
}
// WRONG ANSWER ON TEST 2: ?_?

void inputer() {
	// take the input ONLY:

}

void outputer() {
	//take the input
	//output inputs...
	//solve();


}

void tracker(int test_case, int wanted) {
	if (wanted != test_case) inputer();
	else outputer();
}

// GENERAL SHORTCUTS AND FUNCTIONS :D
template<typename T>
void vprint(const vector<T> &arr) {
	for (auto i : arr) cout << i << " ";
	cout << nl;
}
template<typename T, typename ABCDEF>
void aprint(T arr[],ABCDEF n) {
	for (ABCDEF i = 0; i < n;i++) { cout << arr[i] << " "; }
	cout << "\n";
}
template<typename T>
T expo(T a, T b) {
	if (b == 0) return 1;
	else if (b == 1) return a;
	if (b % 2 == 0) return expo(a*a % mod,b/2) % mod;
	else return (a*expo(a*a % mod, b/2) % mod) % mod;
}

template<typename T>
T gcd(T a, T b) {
	if (a == 0) return b;
	else return gcd(b%a,a);
}
// ============< DONT TOUCH CODES ABOVE >=============
int isprime[2000000];
vector<int> prime;
void thanos() {
    for (int i = 0;i < 2000000;i++) isprime[i] = 1;
    isprime[0] = isprime[1] = 0;
    for (int j = 4; j < 2000000;j+=2) isprime[j] = 0;
    for (int i = 3;i*i < 2000000;i+=2) {
        for (int j = i*i; j < 2000000;j += i) isprime[j] = 0;
    }
    prime.pb(2);
    for (int i = 3;i < 2000000;i+=2) if(isprime[i]) prime.pb(i);
}

// ============< DONT also TOUCH CODES ABOVE >=============

void init() {
    //thanos();
}

void solve() {
    lint n; cin >> n;
    vector<pair<lint,lint>> arr(n+1);
    for (lint i = 1; i < n;i++) cin >> arr[i].first >> arr[i].second;
    sort(arr.begin(),arr.end());
    vector<lint> prefix(n+1);prefix[0] = 0ll;
    for (lint i = 1;i<=n;i++) prefix[i] = (long long)prefix[i-1] + arr[i].second;
    vector<lint,lint> up; vector<pair<lint,lint> down;
    for (lint i = 1; i <= n;i++) up.pb({prefix[i] - arr[i].first,i});
    for (lint i = 1; i <= n;i++) down.pb({prefix[i-1] - arr[i].first,i});
    sort(up.rbegin(),up.rend());
    sort(down.begin(),down.end());
    lint ans = 0ll;
    for (lint i = 1; i <= n;i++) for (lint j = 1;j <= n;j++) {
        if (up[i].second >= down[j].second) ans = max(ans,up[i].first - down[j].first);
    }
    cout << ans << nl;

}


int main()
{
	//freo("div7");

	fastIO();

    long long int t=1;
    //cin >> t;

	init();
    for (int aura = 0; aura < t; aura++) {
        //cout << "-------\n";
        //cout << "Case #" <<aura+1 << ":";
		solve();
    }


    //wrong answer finder: XD
    /*
    if (t != 100) {
		while(t--) solve();
    } else {
		for (int aura = 1; aura <= t;aura++) {
			tracker(aura,68);
		}
    }
    */
    return 0;
}

Compilation message (stderr)

In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from art.cpp:1:
/usr/include/c++/13/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<long long int, long long int>':
/usr/include/c++/13/bits/stl_vector.h:428:11:   required from 'class std::vector<long long int, long long int>'
art.cpp:96:23:   required from here
/usr/include/c++/13/bits/stl_vector.h:88:28: error: 'long long int' is not a class, struct, or union type
   88 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:90:9: error: 'long long int' is not a class, struct, or union type
   90 |         pointer;
      |         ^~~~~~~
/usr/include/c++/13/bits/stl_vector.h: In instantiation of 'class std::vector<long long int, long long int>':
art.cpp:96:23:   required from here
/usr/include/c++/13/bits/stl_vector.h:443:64: error: 'long long int' is not a class, struct, or union type
  443 |       static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
      |                                                                ^~~~~
/usr/include/c++/13/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<long long int, long long int>::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
art.cpp: In function 'void solve()':
art.cpp:96:23: error: use of deleted function 'std::vector<_Tp, _Alloc>::vector() [with _Tp = long long int; _Alloc = long long int]'
   96 |     vector<lint,lint> up; vector<pair<lint,lint> down;
      |                       ^~
/usr/include/c++/13/bits/stl_vector.h:531:7: note: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = long long int; _Alloc = long long int]' is implicitly deleted because the default definition would be ill-formed:
  531 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/13/bits/stl_vector.h:531:7: error: use of deleted function 'std::_Vector_base<_Tp, _Alloc>::_Vector_base() [with _Tp = long long int; _Alloc = long long int]'
/usr/include/c++/13/bits/stl_vector.h:315:7: note: 'std::_Vector_base<_Tp, _Alloc>::_Vector_base() [with _Tp = long long int; _Alloc = long long int]' is implicitly deleted because the default definition would be ill-formed:
  315 |       _Vector_base() = default;
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:315:7: error: no matching function for call to 'std::_Vector_base<long long int, long long int>::_Vector_impl::_Vector_impl()'
/usr/include/c++/13/bits/stl_vector.h:154:9: note: candidate: 'constexpr std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl(std::_Vector_base<_Tp, _Alloc>::_Vector_impl&&) [with _Tp = long long int; _Alloc = long long int]'
  154 |         _Vector_impl(_Vector_impl&& __x) noexcept
      |         ^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:154:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/13/bits/stl_vector.h:137:9: note: candidate: 'constexpr std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() requires  is_default_constructible_v<typename __gnu_cxx::__alloc_traits<_Allocator, typename _Allocator::value_type>::rebind::other> [with _Tp = long long int; _Alloc = long long int]'
  137 |         _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
      |         ^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:137:9: note: constraints not satisfied
art.cpp:96:50: error: template argument 1 is invalid
   96 |     vector<lint,lint> up; vector<pair<lint,lint> down;
      |                                                  ^~~~
art.cpp:96:50: error: template argument 2 is invalid
art.cpp:97:39: error: no matching function for call to 'std::vector<long long int, long long int>::push_back(<brace-enclosed initializer list>)'
   97 |     for (lint i = 1; i <= n;i++) up.pb({prefix[i] - arr[i].first,i});
      |                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = long long int; value_type = long long int]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<long long int, long long int>::value_type&' {aka 'const long long int&'}
 1281 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = long long int; _Alloc = long long int; value_type = long long int]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long long int, long long int>::value_type&&' {aka 'long long int&&'}
 1298 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
art.cpp:98:34: error: 'down' was not declared in this scope
   98 |     for (lint i = 1; i <= n;i++) down.pb({prefix[i-1] - arr[i].first,i});
      |                                  ^~~~
art.cpp:99:13: error: 'class std::vector<long long int, long long int>' has no member named 'rbegin'
   99 |     sort(up.rbegin(),up.rend());
      |             ^~~~~~
art.cpp:99:25: error: 'class std::vector<long long int, long long int>' has no member named 'rend'
   99 |     sort(up.rbegin(),up.rend());
      |                         ^~~~
art.cpp:100:10: error: 'down' was not declared in this scope
  100 |     sort(down.begin(),down.end());
      |          ^~~~
art.cpp:103:15: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'long long int')
  103 |         if (up[i].second >= down[j].second) ans = max(ans,up[i].first - down[j].first);
      |               ^
art.cpp:103:61: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'long long int')
  103 |         if (up[i].second >= down[j].second) ans = max(ans,up[i].first - down[j].first);
      |                                                             ^
art.cpp: In function 'void freo(std::string)':
art.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~