Submission #892285

# Submission time Handle Problem Language Result Execution time Memory
892285 2023-12-25T06:45:15 Z AI_2512 Divide and conquer (IZhO14_divide) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define form(mt) for(auto vec:mt){for (auto el:vec){cout << el << " ";} cout << "\n";}
#define forv(vec) for (auto el:vec){cout <<el.second << " ";}

struct camp{
  int x, g, e;
};

signed main() {
  long long n, maxx = 0;
  cin >> n;
  vector<camp> vec(n);
  for (int i = 0; i< n; i++) cin >> vec[i].x >> vec[i].g >> vec[i].e;

  for (int i = 0; i<n; i++){
    long long esum=0,gsum=0,xsum=0;
    int k = i;
    // for (int k = i; k<n; k++){
    //   esum +=vec[k].e;
    //   xsum +=vec[k].x;
    //   if (esum < xsum){
    //     break;
    //   }else{
    //     gsum += vec[k].g;
    //   }
    // }
    do{
      esum+=vec[k].e;
      xsum +=vec[k].x;
      gsum += vec[k].g;
      k++;
    }while(esum >= xsum && k<=n-1);
    maxx = max(gsum, maxx);
  }
  cout << maxx;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -