답안 #924670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924670 2024-02-09T11:58:55 Z iMeAndMyself 지구 온난화 (NOI13_gw) C++14
6 / 40
2 ms 348 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,vf=0,it=0,maxi=0,mini,j,h;
    cin>>n;
    ll v[1001],a[1001];
    for(i=1; i<=n; i++)
        cin>>v[i];
    v[0]=0, v[n+1]=0;
    mini=21;
    for(i=2; i<n; i++)
        if(v[i]<v[i-1]&&v[i]<=v[i+1]||v[i]<=v[i-1]&&v[i]<v[i+1])
        {
            it++;
            a[it]=v[i];
            if(v[i]>maxi)
                maxi=v[i];
        }
    if(v[1]<v[2])
    {
        it++;
        a[it]=v[1];
    }
    if(v[n]<v[n-1])
    {
        it++;
        a[it]=v[n];
    }
    for(i=1; i<it; i++)
        for(j=i+1; j<=n; j++)
            if(a[i]==a[j])
            {
                for(h=j; h<n; h++)
                    a[h]=a[h+1];
                it--;
            }
    maxi=0;
    for(i=1; i<=it; i++)
    {
        int st=1,nr=0,dr;
        while(st<=n)
        {
            dr=st+1;
            if(v[st]>a[i])
            {
                while(dr<=n&&v[dr]>a[i])
                    dr++;
                if(v[dr]<=a[i])
                    nr++;
                st=dr;
            }
            st++;
        }
        if(nr>maxi)
            maxi=nr;
    }
    cout<<maxi;

    return 0;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:14:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   14 |         if(v[i]<v[i-1]&&v[i]<=v[i+1]||v[i]<=v[i-1]&&v[i]<v[i+1])
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~
gw.cpp:6:13: warning: unused variable 'vf' [-Wunused-variable]
    6 |     int n,i,vf=0,it=0,maxi=0,mini,j,h;
      |             ^~
gw.cpp:6:30: warning: variable 'mini' set but not used [-Wunused-but-set-variable]
    6 |     int n,i,vf=0,it=0,maxi=0,mini,j,h;
      |                              ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -