Submission #714824

#TimeUsernameProblemLanguageResultExecution timeMemory
714824BidoTeimaGlobal Warming (NOI13_gw)C++17
19 / 40
1068 ms65536 KiB
/* ID: BidoTeima LANG: C++11 TASK: */ #include <bits/stdc++.h> using namespace std; using ll = long long; void moo(string filename); void ACPLS(string str = "") { if(str=="NOF")return; if(str.size() && str != "IIOT") moo(str); else if(str != "IIOT"){ #ifndef ONLINE_JUDGE freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); #endif } ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void moo(string fileName){ freopen((fileName+".in").c_str(),"r",stdin); freopen((fileName+".out").c_str(),"w",stdout); } #define tcccc \ int tttttt/*,subtask*/; \ cin >> tttttt/* >> subtask*/; \ while (tttttt--)/*end */ int main() { //ACPLS(""); int n; cin>>n; n += 2; int a[n], cur = 1; a[0] = 0; for(int i = 1; i < n - 1; i++){ cin>>a[i]; } a[n - 1] = 0; vector<int>c; for(int i = 0; i < n; i++){ if(i && a[i] == a[i - 1])continue; c.push_back(a[i]); } n = (int)c.size(); map<int,vector<int>>mp{}; for(int i = 0; i < n; i++){ mp[c[i]].push_back(i); } int ans = 1; for(auto&it:mp){ int x = it.first; if(!x)continue; vector<int>&v = it.second; for(int i = 0; i < (int)v.size(); i++){ assert(v[i] - 1 >= 0); assert(v[i] + 1 < n); int val = (c[v[i] - 1] < x) + (c[v[i] + 1] < x); if(val == 0){ cur++; } else if(val == 2){ cur--; } } ans = max(ans, cur); } cout<<ans<<'\n'; }

Compilation message (stderr)

gw.cpp: In function 'void ACPLS(std::string)':
gw.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
gw.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gw.cpp: In function 'void moo(std::string)':
gw.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gw.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...