답안 #699111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699111 2023-02-15T15:54:17 Z DennisTran Lasers (NOI19_lasers) C++17
100 / 100
434 ms 23476 KB
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define ii pair <int, int>
#define fi first
#define se second
using namespace std;

const int MAXN = 5e5 + 5;

int L, R, a[MAXN], sum[MAXN];
map <int, int> mp;
void solve(void) {
    cin >> L >> R;
    FOR(i, 1, R) {
        int n; cin >> n;
        int D = L;
        FOR(i, 1, n) cin >> a[i], sum[i] = sum[i - 1] + a[i], D -= a[i];
        sum[n + 1] = L;
        FOR(i, 0, n) {
            int l = sum[i] + D + 1;
            int r = sum[i + 1];
            if (r >= l) mp[l]++, mp[r + 1]--;
            //if (r >= l) cout << l << ' ' << r << '\n';
        }
        //cout << '\n';
    }
    int ans = 0, sum = 0;
    for (auto it = mp.begin(); it != mp.end() && next(it) != mp.end(); it++) {
        sum += it -> se;
        if (sum > 0) ans += next(it) -> fi - it ->fi;
    }
    cout << ans;
}

signed main(void) {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    file("LASERS");
    //int T; cin >> T; while (T--) 
    solve();
    cerr << "Time elapsed: " << TIME << " s.\n";
    return (0 ^ 0);
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:9:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp:44:5: note: in expansion of macro 'file'
   44 |     file("LASERS");
      |     ^~~~
lasers.cpp:9:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp:44:5: note: in expansion of macro 'file'
   44 |     file("LASERS");
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 65 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 316 ms 20004 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 16108 KB Output is correct
2 Correct 14 ms 3116 KB Output is correct
3 Correct 10 ms 2132 KB Output is correct
4 Correct 81 ms 18036 KB Output is correct
5 Correct 29 ms 7356 KB Output is correct
6 Correct 36 ms 7552 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 55 ms 7884 KB Output is correct
9 Correct 63 ms 13084 KB Output is correct
10 Correct 96 ms 19968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 16108 KB Output is correct
2 Correct 14 ms 3116 KB Output is correct
3 Correct 10 ms 2132 KB Output is correct
4 Correct 81 ms 18036 KB Output is correct
5 Correct 29 ms 7356 KB Output is correct
6 Correct 36 ms 7552 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 55 ms 7884 KB Output is correct
9 Correct 63 ms 13084 KB Output is correct
10 Correct 96 ms 19968 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 283 ms 18104 KB Output is correct
22 Correct 62 ms 5884 KB Output is correct
23 Correct 24 ms 4940 KB Output is correct
24 Correct 87 ms 15092 KB Output is correct
25 Correct 299 ms 17936 KB Output is correct
26 Correct 117 ms 11152 KB Output is correct
27 Correct 45 ms 4952 KB Output is correct
28 Correct 296 ms 17904 KB Output is correct
29 Correct 290 ms 18116 KB Output is correct
30 Correct 79 ms 10920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 65 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 316 ms 20004 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 83 ms 16108 KB Output is correct
22 Correct 14 ms 3116 KB Output is correct
23 Correct 10 ms 2132 KB Output is correct
24 Correct 81 ms 18036 KB Output is correct
25 Correct 29 ms 7356 KB Output is correct
26 Correct 36 ms 7552 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 55 ms 7884 KB Output is correct
29 Correct 63 ms 13084 KB Output is correct
30 Correct 96 ms 19968 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 283 ms 18104 KB Output is correct
42 Correct 62 ms 5884 KB Output is correct
43 Correct 24 ms 4940 KB Output is correct
44 Correct 87 ms 15092 KB Output is correct
45 Correct 299 ms 17936 KB Output is correct
46 Correct 117 ms 11152 KB Output is correct
47 Correct 45 ms 4952 KB Output is correct
48 Correct 296 ms 17904 KB Output is correct
49 Correct 290 ms 18116 KB Output is correct
50 Correct 79 ms 10920 KB Output is correct
51 Correct 33 ms 6608 KB Output is correct
52 Correct 340 ms 22476 KB Output is correct
53 Correct 322 ms 22612 KB Output is correct
54 Correct 76 ms 7792 KB Output is correct
55 Correct 188 ms 18584 KB Output is correct
56 Correct 91 ms 15836 KB Output is correct
57 Correct 131 ms 13788 KB Output is correct
58 Correct 434 ms 23476 KB Output is correct
59 Correct 86 ms 10572 KB Output is correct
60 Correct 131 ms 12532 KB Output is correct