Submission #321451

# Submission time Handle Problem Language Result Execution time Memory
321451 2020-11-12T11:22:07 Z tjdgus4384 None (KOI16_dd) C++14
100 / 100
94 ms 6848 KB
#include<bits/stdc++.h>
using namespace std;
int N, x, y, a, b, c;
set<pair<int, long long> > s;
vector<pair<int, pair<int, int> > > v;

int main(){
    scanf("%d", &N);
    scanf("%d %d", &x, &y);
    s.insert({x, 0});
    for(int i = 0;i < N;i++){
        scanf("%d %d %d", &a, &b, &c);
        v.push_back({a, {b, c}});
    }
    sort(v.begin(), v.end());
    for(int i = 0;i < N;i++){
        a = v[i].first;
        b = v[i].second.first;
        c = v[i].second.second;
        set<pair<int, long long> >::iterator it;
        it = s.lower_bound({b+1, 0});
        vector<pair<int, long long> > m1, m2;
        while(it != s.end()){
            int yt = (*it).first;
            if(yt >= c) break;
            long long len = (*it).second;
            m1.push_back({b, len+(long long)yt-(long long)b});
            m2.push_back({c, len+(long long)c-(long long)yt});
            set<pair<int, long long> >::iterator tmp = it;
            it++;
            s.erase(tmp);
        }
        if(!m1.empty()){
            sort(m1.begin(), m1.end());
            sort(m2.begin(), m2.end());
            s.insert(m1.front());
            s.insert(m2.front());
        }
    }
    set<pair<int, long long> >::iterator it;
    long long ans = 1e18, cnt = 0;
    vector<int> chk;
    it = s.begin();
    while(it != s.end()){
        if(ans == (*it).second){
            cnt++; chk.push_back((*it).first);
        }
        else if(ans > (*it).second){
            ans = (*it).second;
            cnt = 1; chk.clear(); chk.push_back((*it).first);
        }
        it++;
    }
    printf("%lld\n%d", ans+y, cnt);
    for(int i = 0;i < chk.size();i++){
        printf(" %d", chk[i]);
    }
    return 0;
}

Compilation message

dd.cpp: In function 'int main()':
dd.cpp:54:20: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=]
   54 |     printf("%lld\n%d", ans+y, cnt);
      |                   ~^          ~~~
      |                    |          |
      |                    int        long long int
      |                   %lld
dd.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i = 0;i < chk.size();i++){
      |                   ~~^~~~~~~~~~~~
dd.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
dd.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d %d", &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~
dd.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         scanf("%d %d %d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 6 ms 748 KB Output is correct
37 Correct 7 ms 748 KB Output is correct
38 Correct 4 ms 748 KB Output is correct
39 Correct 5 ms 620 KB Output is correct
40 Correct 6 ms 620 KB Output is correct
41 Correct 4 ms 748 KB Output is correct
42 Correct 70 ms 3760 KB Output is correct
43 Correct 90 ms 3688 KB Output is correct
44 Correct 42 ms 3556 KB Output is correct
45 Correct 61 ms 3556 KB Output is correct
46 Correct 79 ms 3556 KB Output is correct
47 Correct 36 ms 3556 KB Output is correct
48 Correct 67 ms 3484 KB Output is correct
49 Correct 60 ms 3552 KB Output is correct
50 Correct 43 ms 3464 KB Output is correct
51 Correct 40 ms 3920 KB Output is correct
52 Correct 57 ms 3676 KB Output is correct
53 Correct 37 ms 3656 KB Output is correct
54 Correct 43 ms 3804 KB Output is correct
55 Correct 7 ms 748 KB Output is correct
56 Correct 8 ms 748 KB Output is correct
57 Correct 63 ms 3744 KB Output is correct
58 Correct 94 ms 6848 KB Output is correct
59 Correct 6 ms 744 KB Output is correct