답안 #664804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
664804 2022-11-27T08:41:35 Z Astrayt Money (IZhO17_money) C++17
0 / 100
1 ms 212 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, cnt = 0;
    for(int i = 1, flag = 1; i < n; ++i){
        if(v[i].ss == 1 && v[i - 1].ss == 1) continue;
        if(v[i].ss != v[i - 1].ss + 1) ans++, cnt += (v[i].ss == 1);
        else if(v[i - 1].ss == 1) ans++;
    }
    cout << ans - cnt + 1 << '\n';
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}

Compilation message

money.cpp: In function 'void solve()':
money.cpp:37:20: warning: unused variable 'flag' [-Wunused-variable]
   37 |     for(int i = 1, flag = 1; i < n; ++i){
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -