QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#886033#10050. Bitaro the Brave 2lichenghanCompile Error//C++17688b2025-02-06 20:13:182025-02-06 20:13:18

Judging History

This is the latest submission verdict.

  • [2025-02-06 20:13:18]
  • Judged
  • [2025-02-06 20:13:18]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+10;
struct data{
	int a,b;
	friend data operator+(const data& ls,const data& rs){
		return {max(ls.a,rs.a-ls.b),ls.b+rs.b};
	}
};
int n;
data a[N];
data pre[N],suf[N];
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i].a);
	}
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i].b);
	}
	for(int i=1;i<=n;i++){
		if(i==1) pre[i]=a[i];
		else pre[i]=pre[i-1]+a[i];
	}
	for(int i=n;i>=1;i--){
		if(i==n) suf[i]=a[i];
		else suf[i]=a[i]+suf[i+1];
	}
	int ans=1e18;
	for(int i=1;i<=n;i++){
		ans=min(ans,(suf[i]+pre[i-1]).a);
	}
	printf("%lld\n",ans);
}

Details

answer.code:12:1: error: reference to ‘data’ is ambiguous
   12 | data a[N];
      | ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: ‘template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)’
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
answer.code:5:8: note:                 ‘struct data’
    5 | struct data{
      |        ^~~~
answer.code:13:1: error: reference to ‘data’ is ambiguous
   13 | data pre[N],suf[N];
      | ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: ‘template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)’
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])’
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)’
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 ‘template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)’
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
answer.code:5:8: note:                 ‘struct data’
    5 | struct data{
      |        ^~~~
answer.code: In function ‘int main()’:
answer.code:17:31: error: ‘a’ was not declared in this scope
   17 |                 scanf("%lld",&a[i].a);
      |                               ^
answer.code:20:31: error: ‘a’ was not declared in this scope
   20 |                 scanf("%lld",&a[i].b);
      |                               ^
answer.code:23:26: error: ‘pre’ was not declared in this scope; did you mean ‘pread’?
   23 |                 if(i==1) pre[i]=a[i];
      |                          ^~~
      |                          pread
answer.code:23:33: error: ‘a’ was not declared in this scope
   23 |                 if(i==1) pre[i]=a[i];
      |                                 ^
answer.code:24:22: error: ‘pre’ was not declared in this scope; did you mean ‘pread’?
   24 |                 else pre[i]=pre[i-1]+a[i];
      |                      ^~~
      |                      pread
answer.code:24:38: error: ‘a’ was not declared in this scope
   24 |                 else pre[i]=pre[i-1]+a[i];
      |                                      ^
answer.code:27:26: error: ‘suf’ was not declared in this scope
   27 |                 if(i==n) suf[i]=a[i];
      |                          ^~~
answer.code:27:33: error: ‘a’ was not declared in this scope
   27 |                 if(i==n) suf[i]=a[i];
      |                                 ^
answer.code:28:22: error: ‘suf’ was not declared in this scope
   28 |                 else suf[i]=a[i]+suf[i+1];
      |                      ^~~
answer.code:28:29: error: ‘a’ was not declared in this scope
   28 |                 else suf[i]=a[i]+suf[i+1];
      |                             ^
answer.code:32:30: error: ‘suf’ was not declared in this scope
   32 |                 ans=min(ans,(suf[i]+pre[i-1]).a);
      |                              ^~~
answer.code:32:37: error: ‘pre’ was not declared in this scope; did you mean ‘pread’?
   32 |                 ans=min(ans,(suf[i]+pre[i-1]).a);
      |                                     ^~~
      |                                     pread
answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%lld",&n);
      |         ~~~~~^~~~~~~~~~~