답안 #239827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239827 2020-06-17T11:02:43 Z mhy908 Lasers (NOI19_lasers) C++14
0 / 100
1000 ms 3576 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;
typedef long long LL;
int n, q;
struct FENWICK{
    int tree[500010];
    int sum(int i){
        int ans=0;
        while(i){
            ans+=tree[i];
            i-=(i&-i);
        }
        return ans;
    }
    void update(int i, int num){
        while(i<=500000){
            tree[i]+=num;
            i+=(i&-i);
        }
    }
}fen;
int arr[500010], sum[500010], ans;
int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<=q; i++){
        int sz;
        scanf("%d", &sz);
        for(int j=1; j<=sz; j++){
            scanf("%d", &arr[j]);
            sum[j]+=arr[j];
        }
        for(int j=1; j<=sz; j++){
            int e=sum[j], s=n-(sum[sz]-sum[j-1])+1;
            if(s<=e){
                fen.update(s, 1);
                fen.update(e+1, -1);
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(fen.sum(i)-fen.sum(i-1))ans++;
    }
    printf("%d", ans);
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
lasers.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &sz);
         ~~~~~^~~~~~~~~~~
lasers.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &arr[j]);
             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 47 ms 3576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 47 ms 3576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -