Submission #734386

#TimeUsernameProblemLanguageResultExecution timeMemory
734386AmaarsaaGlobal Warming (NOI13_gw)C++14
6 / 40
1078 ms48948 KiB
#include<bits/stdc++.h> using namespace std; using ll = int; ll n, ans, p, j, s, x; int main() { ll i, t, r; cin >> n; map < int, int > Used, Howmuch; vector < pair < ll, ll > > v; for ( i = 1; i <= n; i ++) { cin >> x; Howmuch[x] ++; v.push_back(make_pair(x, i)); } ans = 0; sort ( v.begin(), v.end()); r = 0; for ( i = n - 1; i >= 0; i --) { x = v[i].second; if ( Howmuch[v[i].first] == 1) { ans ++; if ( Used[x + 1] == 1) ans --; if ( Used[x - 1] == 1) ans --; Used[x] ++; } Howmuch[v[i].first] --; r = max (r, ans); } cout << r << endl; }

Compilation message (stderr)

gw.cpp: In function 'int main()':
gw.cpp:7:8: warning: unused variable 't' [-Wunused-variable]
    7 |  ll i, t, r;
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...