Submission #786105

# Submission time Handle Problem Language Result Execution time Memory
786105 2023-07-18T03:32:56 Z devariaota Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

   ll arr[100000];
   ll sumtotal = 0, sum = 0;
 
 void findsum(ll a, ll b, ll idx, ll sum){
   if(a == idx){
     arr[sum]++;
     sumtotal += sum;
     return;
     }
   for(int i = 1; i <= b; i++){
     findsum(a, b, idx+1, sum+i);
   }
 }
 
 int main(){
   ll n, m;
   for(int i = 0; i < 100; i++){
     arr[i] = 0;
   }
   cin >> n >> m;
    // for(ll i = 1; i <= m; i++){
      // for(ll j = 1; j <= m; j++){
        // for(int k = 1; k <= m; k++){
          // for(int x = 1; x <= m; x++){
            // cout << i << j << k << x << " " << i + j + k + x << endl;
            // sumtotal += i + j + k + x;
            // arr[i+j+k+x]++;
//             
          // }
        // }
      // }
    // }
//    
   findsum(n, m, 0, 0);
   for(int i = 0; i < 100003; i++){
     if(arr[i] != 0) sum+=i;
   }
   cout << sum;
 }

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:40:14: warning: iteration 100000 invokes undefined behavior [-Waggressive-loop-optimizations]
   40 |      if(arr[i] != 0) sum+=i;
      |         ~~~~~^
joi2019_ho_t2.cpp:39:21: note: within this loop
   39 |    for(int i = 0; i < 100003; i++){
      |                   ~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -