Submission #239830

# Submission time Handle Problem Language Result Execution time Memory
239830 2020-06-17T11:06:46 Z mhy908 Lasers (NOI19_lasers) C++14
21 / 100
55 ms 7160 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]=sum[j-1]+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))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]);
             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 7160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 7160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -