Submission #786105

#TimeUsernameProblemLanguageResultExecution timeMemory
786105devariaotaExhibition (JOI19_ho_t2)C++17
0 / 100
1 ms212 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...