Submission #732098

# Submission time Handle Problem Language Result Execution time Memory
732098 2023-04-28T11:46:59 Z Trunkty Global Warming (NOI13_gw) C++14
40 / 40
212 ms 22540 KB
#include <bits/extc++.h>
using namespace std;
typedef long long ll;
//#define int ll

int n,curr,ans;
int arr[1000005];
vector<pair<int,int>> v;
bool check[1000005];

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        v.push_back({arr[i],i});
    }
    sort(v.begin(),v.end(),greater<pair<int,int>>());
    for(int i=0;i<v.size();i++){
        int x = v[i].second;
        check[x] = true;
        curr++;
        if(check[x-1]){
            curr--;
        }
        if(check[x+1]){
            curr--;
        }
        if(i==v.size()-1 or v[i+1].first!=v[i].first){
            ans = max(ans,curr);
        }
    }
    cout << ans << "\n";
	return 0;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
gw.cpp:30:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(i==v.size()-1 or v[i+1].first!=v[i].first){
      |            ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1876 KB Output is correct
2 Correct 16 ms 2004 KB Output is correct
3 Correct 16 ms 2004 KB Output is correct
4 Correct 17 ms 2004 KB Output is correct
5 Correct 19 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2004 KB Output is correct
2 Correct 14 ms 2004 KB Output is correct
3 Correct 18 ms 1916 KB Output is correct
4 Correct 17 ms 2004 KB Output is correct
5 Correct 19 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 192 ms 13356 KB Output is correct
2 Correct 212 ms 22540 KB Output is correct
3 Correct 206 ms 22480 KB Output is correct
4 Correct 193 ms 22444 KB Output is correct
5 Correct 203 ms 21804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 13352 KB Output is correct
2 Correct 212 ms 21892 KB Output is correct
3 Correct 193 ms 21788 KB Output is correct
4 Correct 175 ms 15948 KB Output is correct
5 Correct 176 ms 15940 KB Output is correct