Submission #592876

# Submission time Handle Problem Language Result Execution time Memory
592876 2022-07-09T17:22:28 Z hyakup Simple game (IZhO17_game) C++17
0 / 100
1 ms 468 KB
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

const int maxn = 100010;
int bit[maxn], height[maxn];

int n, m;

void update( int i, int v){
    
    for( int j = i; j <= n; j += j&-j) bit[j] += v; 
    
}


int query( int i ){
    
    int soma = 0;
    
    for (int j = i; j > 0; j -= j&-j) soma += bit[j];
    
    return soma;
}


int main()
{
    scanf("%d %d", &n, &m);
    
    
    for( int i = 1; i <= n; i++){
        scanf("%d", &height[i]);
        
        update( height[i], 1 );
        
    }
    
    for( int i = 0; i < m; i++){
        
        int type; scanf("%d", &type);
        
        
        if( type == 1 ){
            int pos, val; scanf("%d %d", &pos, &val);
            
            update( height[pos], -1);
            
            height[pos] = val;
            
            update( height[pos], 1);
        }
        
        else{
            
            int h; scanf("%d", &h);    
            
            printf("%d\n", query(h));
        }
    }
}

Compilation message

game.cpp: In function 'int main()':
game.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
game.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d", &height[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
game.cpp:48:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         int type; scanf("%d", &type);
      |                   ~~~~~^~~~~~~~~~~~~
game.cpp:52:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |             int pos, val; scanf("%d %d", &pos, &val);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~
game.cpp:63:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |             int h; scanf("%d", &h);
      |                    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -