Submission #921162

#TimeUsernameProblemLanguageResultExecution timeMemory
921162vjudge1Airplane (NOI23_airplane)C++17
0 / 100
29 ms1876 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int main() { int n,m; cin>>n>>m; int arr[n]; int mx = 0; vector<int> idx; for(int i =0;i<n;i++){ cin>>arr[i]; mx=max(mx,arr[i]); } int curr = 0; for(int i =0;i<n;i++)if(arr[i]==mx)idx.push_back(i); int cnt = 0; int ans = 0; for(int i = 0;i<idx.size();i++){ if(i==0){ int k = idx[0]; for(int j =1;j<=k;j++){ cnt+=max(1,arr[j]-curr); curr=max(curr,arr[j]); } ans=cnt; } if(i>0)cnt+=idx[i]-idx[i-1]; if(i==idx.size()-1){ break; } } cout<<cnt+ans<<endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0;i<idx.size();i++){
      |                   ~^~~~~~~~~~~
Main.cpp:38:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if(i==idx.size()-1){
      |            ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...