Submission #505667

# Submission time Handle Problem Language Result Execution time Memory
505667 2022-01-11T06:41:05 Z pragmatist Simple game (IZhO17_game) C++17
22 / 100
1000 ms 1576 KB
    #include <bits/stdc++.h>                            
     
    #define pb push_back
    #define sz(v) (int)v.size()
    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define x first
    #define y second
    #define int long long
    #define nl "\n"
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<long long, long long> pll;
    typedef pair <ll, ll> pii;
     
    const int N = (int)1e6 + 7;
    const int M = (int)5e6 + 7;
    const ll MOD = (ll)1e9 + 7;                    
    const int inf = (int)1e9 + 7;
    const ll INF = (ll)3e18 + 7;
     
    pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}};
     
    int n, q, y[N];
     
    void solve() {           
    	cin >> n >> q;
    	for(int i = 1; i <= n; ++i) {
    		cin >> y[i];
    		
    	}
    	while(q--) {
    		char tp;
    		cin >> tp;
    		int c, d;
    		if(tp == '1') {
    			cin >> c >> d;
    			y[c] = d;		
    		} else {
    			cin >> d;
    			int ans = 0;
    			for(int i = 1; i < n; ++i) {
    				int l = min(y[i], y[i + 1]);
					int r = max(y[i], y[i + 1]);
    				if(d >= l && d <= r) ans++;
    			}
    			cout << ans << nl;
    		}
    	}
    }
                    
    signed main() {                   
    	ios_base::sync_with_stdio(NULL);
        cin.tie(0);
        cout.tie(0);
       	int test = 1;
    	//cin >> test;
    	for(int i = 1; i <= test; ++i) {
            //cout << "Case " << i << ": ";
            solve();
        }
        return 0;
    }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 324 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 312 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 324 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 312 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Execution timed out 1092 ms 1576 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 324 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 312 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Execution timed out 1092 ms 1576 KB Time limit exceeded
9 Halted 0 ms 0 KB -