Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pb push_back
- #define ppb pop_back
- #define mp make_pair
- #define all(x) (x).begin(),(x).end()
- #define sz(x) (int)(x).size()
- #define ll long long
- #define bit __builtin_popcountll
- #define sqr(x) (x) * (x)
- #define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
- #define debug(x) cout << #x <<" = " << x << endl
- #define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
- #define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first <<" " << v[i].second << endl;
- #define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;
- using namespace std;
- typedef pair<int, int> pii;
- const double eps = 1e-9;
- const double pi = acos(-1.0);
- const int INF = 1000000000;
- const int dx[4] = {0, 0, 1, -1};
- const int dy[4] = {1, -1, 0, 0};
- const int N = 101;
- int a[N];
- int p = 1;
- ifstream cin1("lazy_loading.txt");
- ofstream cout1("out.txt");
- void solve(){
- int n;
- cin1 >> n;
- for(int i = 0; i < n; i++)
- cin1 >> a[i];
- sort(a, a + n);
- reverse(a, a + n);
- int l = 0;
- int r = n - 1;
- int ans = 0;
- int w = 0;
- while(l < r) {
- w = 0;
- w += a[l];
- while(w < 50 && r > l){
- r--;
- w += a[l];
- }
- ans++;
- l++;
- }
- cout1 <<"Case #" << p++<<": "<< ans << endl;
- }
- int main() {
- ios_base::sync_with_stdio(0);
- int t;
- cin1 >> t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment