Submission #732097

# Submission time Handle Problem Language Result Execution time Memory
732097 2023-04-28T11:46:26 Z Trunkty Global Warming (NOI13_gw) C++14
19 / 40
219 ms 34092 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[100005];

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 16 ms 2004 KB Output is correct
2 Correct 16 ms 2004 KB Output is correct
3 Correct 16 ms 2004 KB Output is correct
4 Correct 16 ms 2004 KB Output is correct
5 Correct 17 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2000 KB Output is correct
2 Correct 13 ms 1996 KB Output is correct
3 Correct 18 ms 2000 KB Output is correct
4 Correct 18 ms 2020 KB Output is correct
5 Correct 18 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 213 ms 34092 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 219 ms 33432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -