Language: C++


AtCoder Beginner Contest 0622017/05/20 21:00:00 ~ 2017/05/20 22:40:00
 トップページ
 問題
 提出
 質問
 結果
 順位表
 コードテスト
 解説
Submission #1456353
ソースコード
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
 
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define rep(i,n) repl(i,0,n-1)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount
 
#define INF INT_MAX/3
 
int main(){
  cin.sync_with_stdio(false);
  priority_queue<int,vector<int>,greater<int> > qmin;
  priority_queue<int> qmax;
 
  int n;
  cin >> n;
  int a[3*n];
  int b[n+1];
  int c[n+1];
  b[0] = 0;
  c[n] = 0;
  rep(i,3*n)cin>>a[i];
  rep(i,n){
    qmax.push(a[3*n-1-i]);
    qmin.push(a[i]);
    b[0] += a[i];
    c[n] += a[3*n-1-i];
  }
  int tmp;
  repl(i,n,2*n-1){
    qmin.push(a[i]);
    tmp = qmin.top();
    qmin.pop();
    b[i-n+1] = b[i-n]+a[i]-tmp;
  }
 
  for(auto i=2*n-1;i>=n;i--){
    qmax.push(a[i]);
    tmp = qmax.top();
    qmax.pop();
    c[i-n] = c[i-n+1]+a[i]-tmp;
  }
  int t= -1000000001;
  rep(i,n+1){
    if(t<b[i]-c[i])t=b[i]-c[i];
  }
  cout << t << endl;
}
Submission
問題	D - 3N Numbers
ユーザ名	getty104
投稿日時	2017/07/28 12:40:28
言語	C++14 (GCC 5.4.1)
状態	WA
得点	0
ソースコード長	1390 Byte
ファイル名	
実行時間	ms
メモリ使用量	-
Test case
Set
Set name	得点 / Max score	Cases
Sample	-	0_00.txt,0_01.txt,0_02.txt
Subtask	0 / 300	0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt
All	0 / 200	0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,1_15.txt,1_16.txt,1_17.txt,1_18.txt,1_19.txt,1_20.txt,1_21.txt,1_22.txt,1_23.txt,2_00.txt,2_01.txt,2_02.txt,2_03.txt,2_04.txt,2_05.txt,2_06.txt,2_07.txt,2_08.txt,2_09.txt,2_10.txt,2_11.txt,2_12.txt,2_13.txt,2_14.txt,2_15.txt
Test case
Case name	状態	実行時間	メモリ使用量
0_00.txt	AC	1 ms	256 KB
0_01.txt	AC	1 ms	256 KB
0_02.txt	AC	1 ms	256 KB
1_00.txt	AC	1 ms	256 KB
1_01.txt	AC	1 ms	256 KB
1_02.txt	AC	1 ms	256 KB
1_03.txt	AC	1 ms	256 KB
1_04.txt	AC	1 ms	256 KB
1_05.txt	AC	1 ms	256 KB
1_06.txt	AC	1 ms	256 KB
1_07.txt	AC	1 ms	256 KB
1_08.txt	AC	1 ms	256 KB
1_09.txt	AC	2 ms	256 KB
1_10.txt	WA
1_11.txt	WA
1_12.txt	WA
1_13.txt	WA
1_14.txt	WA
1_15.txt	WA
1_16.txt	AC	2 ms	256 KB
1_17.txt	AC	2 ms	256 KB
1_18.txt	AC	2 ms	256 KB
1_19.txt	AC	2 ms	256 KB
1_20.txt	WA
1_21.txt	WA
1_22.txt	WA
1_23.txt	WA
2_00.txt	AC	27 ms	3188 KB
2_01.txt	AC	41 ms	3188 KB
2_02.txt	WA
2_03.txt	WA
2_04.txt	WA
2_05.txt	WA
2_06.txt	WA
2_07.txt	WA
2_08.txt	AC	33 ms	3188 KB
2_09.txt	AC	32 ms	3188 KB
2_10.txt	AC	33 ms	3188 KB
2_11.txt	AC	32 ms	3188 KB
2_12.txt	WA
2_13.txt	WA
2_14.txt	WA
2_15.txt	WA
利用規約 プライバシーポリシー 個人情報保護方針 チュートリアル ルール 用語集 よくある質問
© 2017 AtCoder Inc. All rights reserved.

2017-07-28 (Fri)
12:41:32 +0900

Compiler output:
a.cc:11:12: error: stray '#' in program
   11 | Submission #1456353
      |            ^
a.cc:81:20: error: too many decimal points in number
   81 | 言語    C++14 (GCC 5.4.1)
      |                    ^~~~~
a.cc:140:1: error: extended character © is not valid in an identifier
  140 | © 2017 AtCoder Inc. All rights reserved.
      | ^
a.cc:143:11: error: invalid digit "9" in octal constant
  143 | 12:41:32 +0900
      |           ^~~~
a.cc:2:1: error: 'AtCoder' does not name a type
    2 | AtCoder Beginner Contest 0622017/05/20 21:00:00 ~ 2017/05/20 22:40:00
      | ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:13:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
 2086 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
 2087 |     struct remove_extent<_Tp[_Size]>
      |                              ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
 2087 |     struct remove_extent<_Tp[_Size]>
      |                                    ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
 2099 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                   ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                         ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
 2171 |   template<std::size_t _Len>
      |            ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
 2176 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |            ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |                              ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                       ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                           ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
 2202 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
 2203 |         struct __attribute__((__aligned__((_Align)))) { } __align;
      |                                            ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
                 from /usr/include/c++/14/bits/stl_algo.h:69,
                 from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                            ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  132 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  133 | _GLIBC