aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--codechef/gasolineIntroudution.cpp29
-rw-r--r--codechef/icpcBallons.cpp23
3 files changed, 52 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 1a6b07e..67d9de7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
binaries
.ccls-cache
*.o
-
-codechef \ No newline at end of file
diff --git a/codechef/gasolineIntroudution.cpp b/codechef/gasolineIntroudution.cpp
new file mode 100644
index 0000000..8c9201d
--- /dev/null
+++ b/codechef/gasolineIntroudution.cpp
@@ -0,0 +1,29 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int n;
+ cin >> n;
+ vector<int> v(n);
+ for (int &x : v)
+ cin >> x;
+ int sum = v[0];
+ int fuel = v[0];
+ int i = 1;
+ while (fuel) {
+ fuel += v[i];
+ sum += v[i];
+ if (i == n - 1)
+ break;
+ fuel--;
+ i++;
+ }
+ cout << sum << '\n';
+ }
+}
diff --git a/codechef/icpcBallons.cpp b/codechef/icpcBallons.cpp
new file mode 100644
index 0000000..0a66c77
--- /dev/null
+++ b/codechef/icpcBallons.cpp
@@ -0,0 +1,23 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n;
+ cin >> n;
+ vector<int> v(n);
+ int ans = 0;
+ for(int &x : v) cin >> x;
+ for(int i = 0; i < v.size(); i++) {
+ if(v[i] <= 7) {
+ ans = i + 1;
+ }
+ }
+ cout << ans << '\n';
+ }
+}