結果
問題 | No.158 奇妙なお使い |
ユーザー | FF256grhy |
提出日時 | 2020-08-18 15:13:48 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 4,679 bytes |
コンパイル時間 | 2,112 ms |
コンパイル使用メモリ | 200,016 KB |
最終ジャッジ日時 | 2024-11-14 23:22:40 |
合計ジャッジ時間 | 2,547 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In instantiation of 'T vin() [with T = std::array<int, 4>]': main.cpp:46:79: required from 'auto vin(N, M ...) [with T = std::array<int, 4>; N = int; M = {}]' main.cpp:93:29: required from here main.cpp:44:44: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>' and 'std::array<int, 4>') 44 | template<typename T> T vin() { T v; (* IS) >> v; return v; } | ~~~~~~~^~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:120:36: note: no known conversion for argument 1 from 'std::array<int, 4>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define dec(i, n) decID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define MT make_tuple #define FI first #define SE second #define FR front() #define BA back() #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; #define SI(v) static_cast<int>(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) // 以下、入出力関係のテンプレ案のテスト auto * IS = & cin; // input elements (as a tuple) template<typename U, int I> void in_(U & t) { } template<typename U, int I, typename A, typename ... B> void in_(U & t) { (* IS) >> get<I>(t); in_<U, I + 1, B ...>(t); } template<typename ... T> auto in() { tuple<T ...> t; in_<tuple<T ...>, 0, T ...>(t); return t; } // input a array template<typename T, int N> auto ain() { array<T, N> a; inc(i, N) { (* IS) >> a[i]; } return a; } // input a (multi-dimensional) vector // template<typename T> T vin() { return * istream_iterator<T>(* IS); } template<typename T> T vin() { T v; (* IS) >> v; return v; } template<typename T, typename N, typename ... M> auto vin(N n, M ... m) { vector<decltype(vin<T, M ...>(m ...))> v(n); inc(i, n) { v[i] = vin<T, M ...>(m ...); } return v; } // input multi-column (as a tuple of vector) template<typename U, int I> void colin_(U & t) { } template<typename U, int I, typename A, typename ... B> void colin_(U & t) { // get<I>(t).emplace_back(* istream_iterator<A>(* IS)); colin_<U, I + 1, B ...>(t); A a; (* IS) >> a; get<I>(t).push_back(a); colin_<U, I + 1, B ...>(t); } template<typename ... T> auto colin(int n) { tuple<vector<T> ...> t; inc(i, n) { colin_<tuple<vector<T> ...>, 0, T ...>(t); } return t; } auto * OS = & cout; string SP = " ", LN = "\n"; // output elements void out() { (* OS) << LN << flush; } template<typename A > void out(A && a ) { (* OS) << a ; out( ); } template<typename A, typename ... B> void out(A && a, B && ... b) { (* OS) << a << SP; out(b ...); } // output a (multi-dimensional) vector template<typename T> ostream & operator<<(ostream & os, vector<T> const & v) { inc(i, v.size()) { os << (i == 0 ? "" : SP) << v[i]; } return os << flush; } template<typename T> void vout_(T && v) { (* OS) << v; } template<typename T, typename A, typename ... B> void vout_(T && v, A a, B ... b) { for(auto && w: v) { vout_(w, b ...); (* OS) << a; } } template<typename T, typename ... A> void vout(T && v, A ... a) { vout_(v, a ...); out(); } // ---- ---- template<typename T> T MV(T v) { return v; } template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); } template<typename T, size_t N> istream & operator>>(istream & s, array<T, N> & a) { RF(e, a) { s >> e; } return s; } template<typename T, size_t N> ostream & operator<<(ostream & s, array<T, N> const & a) { inc(i, SI(a)) { s << (i == 0 ? "" : " ") << a[i]; } return s; } int main() { const int M = 10000; auto dp = MV<int>(-1, M + 1, M/1000 + 1, M/100 + 1); auto sum = [](int x, int y, int z) { return 1000*x + 100*y + 1*z; }; auto one = [](int s, int x, int y) { return s - (1000*x + 100*y); }; { auto [x, y, z] = ain<int, 3>(); dp[sum(x, y, z)][x][y] = 0; } auto v = vin<array<int, 4>>(2); int ans = 0; decII(s, 0, M) { decII(x, 0, M/1000) { decII(y, 0, M/100) { int z = one(s, x, y); for(auto [ss, xx, yy, zz]: v) { int t = dp[s][x][y]; if(t == -1) { continue; } setmax(ans, t); if(s < ss) { continue; } int sss = s - ss + sum(xx, yy, zz); int X = min(x, ss/1000); ss -= X * 1000; int Y = min(y, ss/100); ss -= Y * 100; int Z = min(z, ss/1); ss -= Z * 1; if(ss != 0) { continue; } setmax(dp[sss][x - X + xx][y - Y + yy], t + 1); } } } } out(ans); }