답안 #239132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239132 2020-06-14T14:34:15 Z Dynamic_Cast Lasers (NOI19_lasers) C++14
65 / 100
1000 ms 45172 KB
//#include <bits/stdc++.h> C++11
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <stack>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int L, R, X, temp;
    cin >> L >> R;
    vi append;
    vector<vi> wall;
    set<int> blocked;
    int flag, maxx;
    flag = 1;
    maxx = 0;
    for (int i = 0; i < R; i++)
    {
        cin >> X;
        if (X > 1)
        {
            flag = 0;
        }
        cin >> temp;
        maxx = max(maxx, temp);
        append.PB(temp);
        for (int j = 1; j < X; j++)
        {
            cin >> temp;
            maxx = max(maxx, temp);
            append.PB(temp+append[j-1]);
        }
        wall.PB(append);
        append.clear();
        
    }
    if (flag == 1)
    {
        cout << max(2 * maxx - L, 0) << "\n";
    }
    if (flag == 0)
    {
        int f2 = 0;
        int space;
        for (int i = 0; i < R; i++)
        {
            for(int j=0;j<int(wall[i].size());j++){
                if(j==0){
                    space=L-(wall[i][int(wall[i].size())-1]-wall[i][j]);
                    //cout<<"space (for wall "<<j<<" in line "<<i<<") = "<<space<<"\n";
                    for(int k=space-wall[i][j];k<wall[i][j];k++){
                        blocked.insert(k);
                        //cout<<k<<"\n";
                    }
                }
                else{
                    space=L-(wall[i][int(wall[i].size())-1]-wall[i][j])-wall[i][j-1];
                    //cout<<"space (for wall "<<j<<" in line "<<i<<") = "<<space<<"\n";
                    for(int k=wall[i][j-1]+space-(wall[i][j]-wall[i][j-1]);k<wall[i][j];k++){
                        blocked.insert(k);
                        //cout<<k<<"\n";
                    }
                }
            }
        }
        cout << int(blocked.size()) << "\n";
    }
    
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:63:13: warning: unused variable 'f2' [-Wunused-variable]
         int f2 = 0;
             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 170 ms 31880 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 165 ms 32432 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 36460 KB Output is correct
2 Correct 245 ms 44808 KB Output is correct
3 Correct 75 ms 17784 KB Output is correct
4 Correct 239 ms 41708 KB Output is correct
5 Correct 290 ms 45172 KB Output is correct
6 Correct 154 ms 34920 KB Output is correct
7 Correct 124 ms 23672 KB Output is correct
8 Correct 87 ms 14568 KB Output is correct
9 Correct 329 ms 44044 KB Output is correct
10 Correct 247 ms 39920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 36460 KB Output is correct
2 Correct 245 ms 44808 KB Output is correct
3 Correct 75 ms 17784 KB Output is correct
4 Correct 239 ms 41708 KB Output is correct
5 Correct 290 ms 45172 KB Output is correct
6 Correct 154 ms 34920 KB Output is correct
7 Correct 124 ms 23672 KB Output is correct
8 Correct 87 ms 14568 KB Output is correct
9 Correct 329 ms 44044 KB Output is correct
10 Correct 247 ms 39920 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 151 ms 31856 KB Output is correct
22 Execution timed out 1101 ms 44408 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 170 ms 31880 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 165 ms 32432 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 215 ms 36460 KB Output is correct
22 Correct 245 ms 44808 KB Output is correct
23 Correct 75 ms 17784 KB Output is correct
24 Correct 239 ms 41708 KB Output is correct
25 Correct 290 ms 45172 KB Output is correct
26 Correct 154 ms 34920 KB Output is correct
27 Correct 124 ms 23672 KB Output is correct
28 Correct 87 ms 14568 KB Output is correct
29 Correct 329 ms 44044 KB Output is correct
30 Correct 247 ms 39920 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 151 ms 31856 KB Output is correct
42 Execution timed out 1101 ms 44408 KB Time limit exceeded
43 Halted 0 ms 0 KB -