Submission #633548

# Submission time Handle Problem Language Result Execution time Memory
633548 2022-08-22T17:36:02 Z Ahmed57 Global Warming (NOI13_gw) C++14
19 / 40
1000 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;
long long n;
long long pre[10000005];
vector<long long> v,w;
map<long long,long long> sa,cmp;
int main(){
    cin>>n;
    v.push_back(2);
    for(int i = 0;i<n;i++){
        long long x;cin>>x;
        w.push_back(x);
        sa[x]++;
    }
    long long z = 1;
    for(auto i:sa){
        cmp[i.first] = ++z;
    }
    int pre[z*2+5]  = {0};
    for(int i = 0;i<w.size();i++){
        v.push_back(cmp[w[i]]*2);
    }
    for(int i = 0;i<v.size()-1;i++){
        if(v[i]<v[i+1]){
            pre[v[i+1]]--;
            pre[v[i]]++;
        }
    }
    long long ma = 0 , cur = 0;
    for(int i = 2;i<=z*2;i++){
        cur+=pre[i];
        ma = max(ma,cur);
    }
    cout<<ma<<"\n";
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i = 0;i<w.size();i++){
      |                   ~^~~~~~~~~
gw.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0;i<v.size()-1;i++){
      |                   ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2588 KB Output is correct
2 Correct 22 ms 2584 KB Output is correct
3 Correct 25 ms 2588 KB Output is correct
4 Correct 24 ms 2632 KB Output is correct
5 Correct 23 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 15824 KB Output is correct
2 Correct 86 ms 15848 KB Output is correct
3 Correct 169 ms 15832 KB Output is correct
4 Correct 131 ms 15896 KB Output is correct
5 Correct 146 ms 15844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 41216 KB Time limit exceeded
2 Halted 0 ms 0 KB -