Submission #258605

#TimeUsernameProblemLanguageResultExecution timeMemory
258605dantoh000Devil's Share (RMI19_devil)C++14
14 / 100
157 ms2168 KiB
#include <bits/stdc++.h>
using namespace std;
int k;
int d[10];
int ans[100005];
int n;
int main(){
    int TC;
    scanf("%d",&TC);
    while (TC--){
        scanf("%d",&k);
        n = 0;
        for (int i = 1; i <= 9; i++){
            scanf("%d",&d[i]);
            n += d[i];
        }
        if (k == 2){
            int F = 1, S = 9;
            for (int i = n-1; i >= 0; i--){
                while (d[F] == 0) F++;
                while (d[S] == 0) S--;
                //printf("%d digit: %d %d\n",i,F,S);
                if ((n-i) % 2 == 1){
                    ans[i] = S;
                    d[S]--;
                }
                else{
                    ans[i] = F;
                    d[F]--;
                }
            }
            for (int i = 0; i < n; i++){
                printf("%d",ans[i]);
            }
            printf("\n");
        }
    }

}

Compilation message (stderr)

devil.cpp: In function 'int main()':
devil.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&TC);
     ~~~~~^~~~~~~~~~
devil.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
devil.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&d[i]);
             ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...