結果
問題 | No.798 コレクション |
ユーザー | Haar |
提出日時 | 2019-03-15 22:10:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,295 bytes |
コンパイル時間 | 1,478 ms |
コンパイル使用メモリ | 164,056 KB |
最終ジャッジ日時 | 2024-11-14 21:19:22 |
合計ジャッジ時間 | 1,827 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In instantiation of 'std::istream& operator>>(std::istream&, std::vector<_Tp>&) [with T = std::pair<long long int, long long int>; std::istream = std::basic_istream<char>]': main.cpp:53:30: required from here main.cpp:36:90: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::pair<long long int, long long int>') 36 | template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;} | ~~~^~~~ 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::pair<long long int, long long int>' 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/is
ソースコード
#include <bits/stdc++.h> #define FOR(v, a, b) for(int v = (a); v < (b); ++v) #define FORE(v, a, b) for(int v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define REPE(v, n) FORE(v, 0, n) #define REV(v, a, b) for(int v = (a); v >= (b); --v) #define ALL(x) (x).begin(), (x).end() #define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it) #define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it) #define EXIST(c,x) ((c).find(x) != (c).end()) #define LLI long long int #define fst first #define snd second #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #ifndef M_E #define M_E 2.71828182845904523536 #endif #ifdef DEBUG #include <misc/C++/Debug.cpp> #else #define dump(x) #endif #define pln(x) cout << (x) << endl #define gcd __gcd using namespace std; template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;} template <typename T> using V = vector<T>; template <typename T, typename U> using P = pair<T,U>; template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;} template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;} template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;} template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);} template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);} template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);} using pll = pair<LLI,LLI>; LLI dp[2100][2100]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; while(cin >> N){ vector<pll> d(N); cin >> d; sort(ALL(d), [](pll &x, pll &y){return x.snd > y.snd;}); vector<LLI> sum(N+1); REP(i,N) sum[i+1] = sum[i] + d[i].snd; int camp = N / 3; REP(i,N){ REP(j,camp){ chmax(dp[i+1][j], dp[i][j]); chmax(dp[i+1][j+1], dp[i][j] + d[i].fst + d[i].snd*(i-j) + sum[N] - sum[i+1]); } } LLI ans = 0; REP(i,N) ans += d[i].fst + d[i].snd*i; dump(ans); LLI sub = 0; REPE(i,N) REPE(j,camp) chmax(sub, dp[i][j]); ans -= sub; cout << ans << endl; } return 0; }