int C[6] = {1, 5, 10, 50, 100, 500}; int V[6];//V[0] = C_1; V[1] = C_5; int A; voidsolve(){ int res = 0; for (int i = 5; 0 <= i; i--){ int t = min(A/C[i], V[i]); res += t; A -= t * C[i]; } printf("%d\n", res); }
constint MAX_N = 100000; int N, S[MAX_N], T[MAX_N];
pair<int , int> itv[MAX_N];
voidsolve(){ for (int i = 0; i < N; i++) { itv[i].second = S[i]; itv[i].first = T[i]; } sort(itv, itv + N); int t = 0, ans = 0; for (int i = 0; i < N; i++) { if(itv[i].second > t) { ans ++; t = itv[i].first; } } printf("%d\n", ans); }