답안 #664772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
664772 2022-11-27T08:32:07 Z Astrayt Money (IZhO17_money) C++17
0 / 100
1 ms 284 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define maxn 200005
#define mod 1000000007

void solve(){
    int n; cin >> n;
    vector<pii> v(n);
    for(auto &x:v) cin >> x.ff;
    int id = 1;
    v[0].ss = 1;
    while(id < n && v[id - 1].ff <= v[id].ff) v[id].ss = 1, id++;
    if(id == n){
        cout << 1 << '\n';
        return;
    }
    for(int i = id, cur = 2; i < n; ++i){
        v[i].ss = cur; cur++;
    }
    sort(v.begin(), v.end());
    int ans = 1;
    for(int i = 1, flag = 1; i < n; ++i){
        if(v[i].ss != v[i - 1].ss + 1){
            if(v[i].ss == 1) ans += flag, flag = 0;
            else ans++;
        }else if(v[i - 1].ss == 1) ans++;
    }
    cout << ans << '\n';
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 284 KB Output isn't correct
3 Halted 0 ms 0 KB -