luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/DANDAU #644

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Dãy con đan dấu dài nhất - Luyện Code Online

https://luyencode.net/problem/DANDAU

huydh1900 commented 2 years ago

Tham khao: https://luyencode.net/status/8fe16cfe3d77861f3feb5ed020528a8c?problem=DANDAU

chatctt commented 2 years ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

#include using namespace std; int main() { long long n,a[100000]; cin>>n; int dem=1,res=1; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=2;i<=n;i++) { if(a[i]*a[i-1]<0) dem++; else dem=1; res=max(res,dem); } if(res==1) cout<<-1; else cout<

danh2006 commented 2 years ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

#include #define ll long long using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; ll a[n]; for(ll i=0;i> a[i]; } ll cnt = 1, max = 0, res = 0; for(ll i=1;imax){ max=cnt; } } if(res==0){ cout << "-1"; }else{ cout << max << endl; } }