Submission #1333839
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)
template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
// ---- ----
int n, m;
vector<pair<int, int>> vec[100001];
int dist[100001];
template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
RPQ<pair<Cost, int>> q;
dist[start] = 0;
q.emplace(dist[start], start);
while(! q.empty()) {
auto cp = q.top(); q.pop();
int p = cp.SE;
Cost c = cp.FI;
if(dist[p] != c) { continue; }
for(auto && e : g[p]) {
int ep = e.FI;
Cost ec = e.SE;
if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
}
}
return;
}
int main() {
scanf("%d%d", &n, &m);
inc(i, n) {
int s, l;
scanf("%d%d", &s, &l);
vec[s].EB(s + l, 0);
}
inc(i, m) {
vec[i ].EB(i + 1, 1);
vec[i + 1].EB(i , 1);
}
inc(i, m + 1) { dist[i] = m + 1; }
dijkstra(0, vec, dist);
printf("%d\n", m - dist[m]);
return 0;
}
Submission Info
Submission Time |
|
Task |
H - 焼肉の達人 |
User |
FF256grhy |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2525 Byte |
Status |
AC |
Exec Time |
50 ms |
Memory |
9212 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:66:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:69:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &s, &l);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt |
All |
sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, sample-01.txt, sample-02.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
2 ms |
2560 KB |
01-02.txt |
AC |
16 ms |
3704 KB |
01-03.txt |
AC |
2 ms |
2560 KB |
01-04.txt |
AC |
16 ms |
3692 KB |
01-05.txt |
AC |
16 ms |
3712 KB |
01-06.txt |
AC |
18 ms |
3840 KB |
01-07.txt |
AC |
15 ms |
3712 KB |
01-08.txt |
AC |
16 ms |
3968 KB |
01-09.txt |
AC |
18 ms |
3712 KB |
01-10.txt |
AC |
3 ms |
2688 KB |
01-11.txt |
AC |
13 ms |
6144 KB |
01-12.txt |
AC |
14 ms |
6144 KB |
01-13.txt |
AC |
16 ms |
6144 KB |
01-14.txt |
AC |
21 ms |
6144 KB |
01-15.txt |
AC |
49 ms |
7552 KB |
01-16.txt |
AC |
50 ms |
7552 KB |
01-17.txt |
AC |
50 ms |
7552 KB |
01-18.txt |
AC |
49 ms |
7552 KB |
01-19.txt |
AC |
40 ms |
7680 KB |
01-20.txt |
AC |
42 ms |
7680 KB |
01-21.txt |
AC |
45 ms |
7680 KB |
01-22.txt |
AC |
44 ms |
7680 KB |
01-23.txt |
AC |
45 ms |
7680 KB |
01-24.txt |
AC |
46 ms |
7680 KB |
01-25.txt |
AC |
46 ms |
7680 KB |
01-26.txt |
AC |
46 ms |
7808 KB |
01-27.txt |
AC |
47 ms |
7808 KB |
01-28.txt |
AC |
49 ms |
8064 KB |
01-29.txt |
AC |
50 ms |
8064 KB |
01-30.txt |
AC |
50 ms |
8064 KB |
01-31.txt |
AC |
13 ms |
6144 KB |
01-32.txt |
AC |
13 ms |
6144 KB |
01-33.txt |
AC |
13 ms |
6144 KB |
01-34.txt |
AC |
14 ms |
6144 KB |
01-35.txt |
AC |
18 ms |
6272 KB |
01-36.txt |
AC |
13 ms |
6144 KB |
01-37.txt |
AC |
13 ms |
6144 KB |
01-38.txt |
AC |
21 ms |
6272 KB |
01-39.txt |
AC |
17 ms |
6144 KB |
01-40.txt |
AC |
20 ms |
6144 KB |
01-41.txt |
AC |
40 ms |
8576 KB |
01-42.txt |
AC |
37 ms |
7680 KB |
01-43.txt |
AC |
47 ms |
9212 KB |
01-44.txt |
AC |
37 ms |
7680 KB |
01-45.txt |
AC |
29 ms |
6900 KB |
01-46.txt |
AC |
50 ms |
7552 KB |
01-47.txt |
AC |
42 ms |
7680 KB |
01-48.txt |
AC |
46 ms |
7808 KB |
01-49.txt |
AC |
50 ms |
8064 KB |
sample-01.txt |
AC |
2 ms |
2560 KB |
sample-02.txt |
AC |
2 ms |
2560 KB |