Submission #310708

# Submission time Handle Problem Language Result Execution time Memory
310708 2020-10-07T16:32:05 Z bigDuck Devil's Share (RMI19_devil) C++14
0 / 100
0 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll



ifstream fin("devil.in");
#define cin fin
ofstream fout("devil.out");
#define cout fout



int t, n, m, k, a[300010], q, l, r;
int d[20];
int32_t main(){
INIT
cin>>t;
while(t--){
    cin>>k;
    for(int i=1; i<=9; i++){
        cin>>d[i];
    }
    int dmax=0;
    for(int i=1; i<=9; i++){
    if(d[i]>0){dmax=max(dmax, i);}
    }
    string s="";
    string suf=""; suf.pb('0'+dmax);
    d[dmax]--;
    dmax=0;
    for(int i=9; i>=1; i--){
        if(d[i]>0){dmax=i; break;}
    }

    int sum=0; for(int i=1; i<dmax; i++){if(sum>=d[dmax]){break;} sum+=d[i]; }
    if(sum>=d[dmax]){
        for(int i=1; (i<dmax) && (d[dmax]>0); i++){
            while( (d[i]>0) && (d[dmax]>0) ){s.pb(dmax+'0'); d[dmax]--;if(d[i]>0){s.pb(i+'0'); d[i]--;}  }
        }
    }
    for(int i=1; i<=9; i++){
        for(int j=1; j<=d[i]; j++){s.pb(i+'0');}
    }
    s+=suf;
    int mx=0;
    for(int i=0;i<(s.length()-1); i++){
        mx=max(mx, ((int)10*(s[i]-'0')+(s[i+1]-'0')) );
    }
    cout<<mx;
    cout<<"\n";
}



return 0;
}



Compilation message

devil.cpp: In function 'int32_t main()':
devil.cpp:55:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0;i<(s.length()-1); i++){
      |                 ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Unexpected end of file - token expected
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Unexpected end of file - token expected