CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Sanat
Sender:
Submission time:2015-12-20 16:54:52 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.12 s0details

Code

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N = 45e6;
pair<ll, ll> t[111];
ll mod = 98765431;
ll asd = 1007;
bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a > b;
}
int main() {
    srand(time(0));
    ll rr = rand()%mod;
    int n;
    cin>>n;
    pair<ll, vector<int> > best = {1e18, {0}};
    ll sum = 0;
    ll mi = 1e9;
    for(int i = 0; i < n; ++i) {
        cin>>t[i].F;
        t[i].S = i;

        sum += t[i].F;
        mi = min(t[i].F, mi);
    }
    sort(t, t+n, comp);
    for(int i = 0; i < N/n; ++i) {
        //random_shuffle(t, t+n);
        ll a = sum/2;
        ll left = sum;
        vector<int> v(n);
        for(int j = 0; j < n; ++j) {
            rr *= asd;
            rr %= mod;
            ll r = rr;
            //if(r/1000 < a/left) {
            if(r*left < mod*a) {
            //if(r < 500) {
                left -= t[j].F;
                a -= t[j].F;
                v[t[j].S] = 1;
            }
            else {
                left -= t[j].F;
                v[t[j].S] = 2;
            }
            if(-a > best.F) break;
        }
        a = abs(a);
        best = min(best, {a, v});
    }
    for(int i = 0; i < n; ++i) {
        cout<<best.S[i]<<' ';
    }
    cout<<'\n';
}

Test details

Test 1

Verdict:

input
95000
pursua
zoomata
mantelilastu
jamming
...

correct output
10-4
10-4
10-4
QAQ
QAQ
...

user output
(empty)