답안 #710081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710081 2023-03-15T04:27:26 Z safaricola Money (IZhO17_money) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pi pair <int, int>
#define pii pair <pi, int>
#define rep(i,n) for(ll i = 1; i <= n; i++)
#define fi first
#define se second
using namespace std;
int n, a[1000010],mx,mi;
bool vis[1000010];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
   cin>>n;
   rep(i,n)cin>>a[i];
   int ans=1;
   mx=a[n];
   for(int i=n; i>1; i--){ 
      if(a[i-1]>a[i]){
         mx=a[i-1];
         vis[mi]=true;
         vis[mx]=true;
         ans++;
         //cout<<1;
      }else{
         mi=a[i-1];
         if(a[i]!=a[i-1]+1&&!vis[mx-1]){
            ans++;
            mx=a[i-1];
            vis[mi]=true;
            vis[mx]=true;
            //cout<<2;
         }else if(a[i]!=a[i-1]+1&&!vis[mi+1]){
            cout<<mi+1<<endl;
            rep(i,n)cout<<vis[i];cout<<endl;
            ans++;
            mx=a[i-1];
            vis[mi]=true;
            vis[mx]=true;
            //cout<<3;
         }
      }
      mi=a[i-1];
      //cout<<mi<<' '<<mx<<' '<<ans<<endl;
   }
   cout<<ans;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:6:18: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    6 | #define rep(i,n) for(ll i = 1; i <= n; i++)
      |                  ^~~
money.cpp:35:13: note: in expansion of macro 'rep'
   35 |             rep(i,n)cout<<vis[i];cout<<endl;
      |             ^~~
money.cpp:35:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |             rep(i,n)cout<<vis[i];cout<<endl;
      |                                  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -