Submission #1967217
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tp;
const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;
struct oreno_initializer {
oreno_initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
}
} oreno_initializer;
// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・
int n, a[100100], b[100100], c, ne;
pii dp[1001001];
vi m[1001001];
signed main() {
cin >> n;
rep(i,n) {
cin >> a[i] >> b[i];
m[a[i]].pb(i);
}
// 時刻i以降で同時にできる仕事の最大値、インデックスの最小値
dp[1000000] = {0,inf};
repr(i,999999) {
pii p = dp[i+1];
// 開始時刻がiの仕事それぞれのインデックス
each(j,m[i]) {
if (dp[b[j]].fi+1 > p.fi) {
p.fi = dp[b[j]].fi+1;
p.se = j+1;
} else if (dp[b[j]].fi+1 == p.fi) {
chmin(p.se, j+1);
}
}
dp[i] = p;
}
c = dp[0].fi;
cout << c << ln;
rep(i,c) {
pii p = dp[ne];
cout << p.se;
if (i==c) cout << ln;
else {
cout << ' ';
ne = b[p.se-1];
}
}
}
Submission Info
Submission Time |
|
Task |
C - 仕事計画 |
User |
creep04 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2478 Byte |
Status |
WA |
Exec Time |
49 ms |
Memory |
35712 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt |
All |
0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name |
Status |
Exec Time |
Memory |
0.txt |
WA |
13 ms |
31488 KB |
1.txt |
WA |
13 ms |
31488 KB |
10.txt |
WA |
13 ms |
31488 KB |
11.txt |
WA |
13 ms |
31616 KB |
12.txt |
WA |
13 ms |
31616 KB |
13.txt |
WA |
13 ms |
31616 KB |
14.txt |
WA |
13 ms |
31616 KB |
15.txt |
WA |
13 ms |
31616 KB |
16.txt |
WA |
13 ms |
31616 KB |
17.txt |
WA |
13 ms |
31616 KB |
18.txt |
WA |
26 ms |
32896 KB |
19.txt |
WA |
28 ms |
33024 KB |
2.txt |
WA |
13 ms |
31488 KB |
20.txt |
WA |
44 ms |
35200 KB |
21.txt |
WA |
26 ms |
33024 KB |
22.txt |
WA |
28 ms |
32896 KB |
23.txt |
WA |
49 ms |
35712 KB |
3.txt |
WA |
13 ms |
31488 KB |
4.txt |
WA |
13 ms |
31488 KB |
5.txt |
WA |
13 ms |
31488 KB |
6.txt |
WA |
13 ms |
31488 KB |
7.txt |
WA |
13 ms |
31488 KB |
8.txt |
WA |
13 ms |
31488 KB |
9.txt |
WA |
13 ms |
31488 KB |
sample1.txt |
WA |
13 ms |
31488 KB |
sample2.txt |
WA |
13 ms |
31488 KB |
sample3.txt |
WA |
13 ms |
31488 KB |