답안 #919301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919301 2024-01-31T14:41:46 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
37 ms 1880 KB
/******************************************************************************

                              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]);
    }
    for(int i =0;i<n;i++)if(arr[i]==mx)idx.push_back(i);
    int cnt = 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]-arr[j-1]);
        }
        if(i==idx.size()-1){
            cnt+=mx;
        }
        if(i>0&&i<n-1)cnt+=idx[i]-idx[i-1];
    }
    cout<<cnt<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0;i<idx.size();i++){
      |                   ~^~~~~~~~~~~
Main.cpp:31:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if(i==idx.size()-1){
      |            ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 37 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 37 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -