답안 #341236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341236 2020-12-29T09:21:30 Z Habib_Assoev Simple game (IZhO17_game) C++14
0 / 100
5 ms 4204 KB
# include<bits/stdc++.h>
#define in freopen ("measurement.in", "r", stdin);
#define out freopen("measurement.out", "w", stdout);
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std ;
long long const N = 1e6 + 7;
long long N1 = 1e9 + 7;
double long k = 0;

int a[N], dp[N];

int main( ){
    //in out
    speed ;
    ll TJK = 1 ;
    // cin >> TJK ;
    while( TJK -- ){
        int n, m;
        cin >> n >> m;
        for ( int i = 1; i <= n; i++ ) {
            cin >> a[i];
        }
        for ( int i = 2; i <= n; i++ ) {
            int l = a[i - 1], r = a[i];
            if ( l > r ) {
                swap( l, r );
            }
            dp[l]++;
            dp[r + 1]--;
        }
        for ( int i = 1; i < N; i++ ) {
            dp[i] += dp[i - 1];
        }
        for ( int i = 1; i <= m; i++ ) {
            int t;
            cin >> t;
            if ( t == 2 ) {
                int h, cnt = 0;
                cin >> h;
                cout << dp[h] << '\n';
            }
        }
    }
}

Compilation message

game.cpp: In function 'int main()':
game.cpp:43:24: warning: unused variable 'cnt' [-Wunused-variable]
   43 |                 int h, cnt = 0;
      |                        ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4204 KB Output isn't correct
2 Halted 0 ms 0 KB -