Submission #1240062
Source Code Expand
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
int main(void){
int n; cin >> n;
vector<mp> v(n), vv(n), a(n), b(n);
vector<pair<mp, int>> w(n);
vector<int> m(n+1), mov(n+1);
rep(i, n){
cin >> w[i].fir.fir >> w[i].fir.sec;
w[i].sec = i+1;
}
rep(i, n) vv[i] = w[i].fir;
sort(w.begin(), w.end());
rep(i, n) v[i] = w[i].fir;
rep(i, n) a[i].sec = w[i].sec;
m[n] = 0;
irep(i, n){
int t = lower_bound(v.begin(), v.end(), mp(v[i].sec, 0)) - v.begin();
a[i].fir = m[t]+1;
m[i] = max(m[i+1], a[i].fir);
}
sort(a.begin(), a.end(),
[](const mp& ta, const mp& tb){return (ta.fir!=tb.fir ? ta.fir>tb.fir : ta.sec<tb.sec);}
);
b = a;
reverse(b.begin(), b.end());
cout << a[0].fir << endl;
int pre = 0;
ireg(i, 1, a[0].fir){
int t = upper_bound(b.begin(), b.end(), mp(i, IINF)) - b.begin();
t = n - t;
int c = 0;
if(pre != 0) while(vv[a[t+c].sec-1].fir < vv[pre-1].sec) c++;
cout << (pre = a[t+c].sec) << (i != 1 ? " " : "\n");
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 仕事計画 |
User |
ktyshmt |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1745 Byte |
Status |
AC |
Exec Time |
89 ms |
Memory |
5760 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 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 |
AC |
1 ms |
256 KB |
1.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
1 ms |
256 KB |
11.txt |
AC |
1 ms |
256 KB |
12.txt |
AC |
2 ms |
256 KB |
13.txt |
AC |
2 ms |
256 KB |
14.txt |
AC |
2 ms |
256 KB |
15.txt |
AC |
2 ms |
256 KB |
16.txt |
AC |
2 ms |
256 KB |
17.txt |
AC |
2 ms |
256 KB |
18.txt |
AC |
56 ms |
5376 KB |
19.txt |
AC |
70 ms |
5376 KB |
2.txt |
AC |
1 ms |
256 KB |
20.txt |
AC |
89 ms |
5376 KB |
21.txt |
AC |
55 ms |
5376 KB |
22.txt |
AC |
63 ms |
5376 KB |
23.txt |
AC |
88 ms |
5760 KB |
3.txt |
AC |
1 ms |
256 KB |
4.txt |
AC |
1 ms |
256 KB |
5.txt |
AC |
1 ms |
256 KB |
6.txt |
AC |
1 ms |
256 KB |
7.txt |
AC |
1 ms |
256 KB |
8.txt |
AC |
1 ms |
256 KB |
9.txt |
AC |
1 ms |
256 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |