Submission #00055
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | //#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } typedef long long ll; typedef vector< int > vint; typedef pair< int , int > pint; typedef vector< long long > vlong; typedef vector<string> vstring; #define vpush(a,x) a.push_back(x); #define rep(i, n) REP(i, 0, n) #define all(v) v.begin(), v.end() #define REP(i, x, n) for(int i = x; i < n; i++) const int INF = 1 << 30; const int dx[] = {1,0,-1,0,1,1,-1,-1}; const int dy[] = {0,-1,0,1,1,-1,-1,1}; #define stp(x) setprecision(x) const long double PI=3.14159265358979323846264338327950; int main(){ cin.tie(nullptr); ios::sync_with_stdio( false ); int n; cin>>n; vlong a(n); rep(i,n){ cin>>a[i]; } map<ll, int > M; int cnt=0,fg=0,now=0; bool fg2= false ; rep(i,n){ if (now>a[i] && fg==0){ M[now]--; fg=1; } if (now<a[i] && fg==1){ M[now]++; fg=0; } if (a[i]!=0){ fg2= true ; } now=a[i]; } int max=0; for (auto x:M){ cnt+=x.second; // cout<<x.first<<' '<<x.second<<'\n'; chmax(max,cnt); } if (fg2){ max++; } cout<<max<< '\n' ; return (0); } //#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } typedef long long ll; typedef vector< int > vint; typedef pair< int , int > pint; typedef vector< long long > vlong; typedef vector<string> vstring; #define vpush(a,x) a.push_back(x); #define rep(i, n) REP(i, 0, n) #define all(v) v.begin(), v.end() #define REP(i, x, n) for(int i = x; i < n; i++) const int INF = 1 << 30; const int dx[] = {1,0,-1,0,1,1,-1,-1}; const int dy[] = {0,-1,0,1,1,-1,-1,1}; #define stp(x) setprecision(x) const long double PI=3.14159265358979323846264338327950; int main(){ cin.tie(nullptr); ios::sync_with_stdio( false ); int n; cin>>n; vlong a(n); rep(i,n){ cin>>a[i]; } map<ll, int > M; int cnt=0,fg=0,now=0; bool fg2= false ; rep(i,n){ if (now>a[i] && fg==0){ M[now]--; fg=1; } if (now<a[i] && fg==1){ M[now]++; fg=0; } if (a[i]!=0){ fg2= true ; } now=a[i]; } int max=0; for (auto x:M){ cnt+=x.second; // cout<<x.first<<' '<<x.second<<'\n'; chmax(max,cnt); } if (fg2){ max++; } cout<<max<< '\n' ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 日本沈没 (Japan Sinks) |
ユーザー名 | ei1918 |
投稿日時 | 2020-12-08 17:52:03 |
言語 | C++17 |
状態 | Compile Error |
得点 | 0 |
ソースコード長 | 2734 Byte |
最大実行時間 | - |
最大メモリ使用量 |
コンパイルメッセージ
./Main.cpp:61:41: error: redefinition of ‘template<class A, class B> bool chmax(A&, const B&)’ template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } ^~~~~ ./Main.cpp:4:41: note: ‘template<class A, class B> bool chmax(A&, const B&)’ previously declared here template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } ^~~~~ ./Main.cpp:62:41: error: redefinition of ‘template<class A, class B> bool chmin(A&, const B&)’ template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } ^~~~~ ./Main.cpp:5:41: note: ‘template<class A, class B> bool chmin(A&, const B&)’ previously declared here template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } ^~~~~ ./Main.cpp:72:11: error: redefinition of ‘const int INF’ const int INF = 1 << 30; ^~~ ./Main.cpp:15:11: note: ‘const int INF’ previously defined here const int INF = 1 << 30; ^~~ ./Main.cpp:73:14: error: redefinition of ‘const int dx []’ const int dx[] = {1,0,-1,0,1,1,-1,-1}; ^ ./Main.cpp:16:11: note: ‘const int dx [8]’ previously defined here const int dx[] = {1,0,-1,0,1,1,-1,-1}; ^~ ./Main.cpp:74:14: error: redefinition of ‘const int dy []’ const int dy[] = {0,-1,0,1,1,-1,-1,1}; ^ ./Main.cpp:17:11: note: ‘const int dy [8]’ previously defined here const int dy[] = {0,-1,0,1,1,-1,-1,1}; ^~ ./Main.cpp:76:19: error: redefinition of ‘const long double PI’ const long double PI=3.14159265358979323846264338327950; ^~ ./Main.cpp:19:19: note: ‘const long double PI’ previously defined here const long double PI=3.14159265358979323846264338327950; ^~ ./Main.cpp:77:5: error: redefinition of ‘int main()’ int main(){ ^~~~ ./Main.cpp:20:5: note: ‘int main()’ previously defined here int main(){ ^~~~
セット
セット | 得点 | Cases |
---|
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|