// 基本テンプレート #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define debug(...) fprintf(stderr, __VA_ARGS__) #define int long long int template void chmax(T &a, T b) {a = max(a, b);} template void chmin(T &a, T b) {a = min(a, b);} template void chadd(T &a, T b) {a = a + b;} typedef pair pii; typedef long long ll; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const ll INF = 1001001001001001LL; const ll MOD = 1000000007LL; int N, M; signed main() { cin >> N >> M; vector max_val(M, -1333); vector< vector > max_person(M); int cnt = 0; vector assign_max(N); for(int i=0; i> val; if(max_val[j] < val) { // erase for(auto p : max_person[j]) { assign_max[p]--; if(assign_max[p] == 0) cnt--; } max_person[j].clear(); max_val[j] = val; if(assign_max[i] == 0) cnt++; assign_max[i]++; max_person[j].push_back(i); } else if(max_val[j] == val) { if(assign_max[i] == 0) cnt++; assign_max[i]++; max_person[j].push_back(i); } } cout << cnt << endl; } return 0; }