Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
struct Person {
int index; // Vị trí của người trong hàng
int time; // Thời gian mua vé của người
};
bool compareByTime(const Person& a, const Person& b) {
return a.time < b.time;
}
int main() {
// Đọc dữ liệu từ tệp TICKET.INP
std::ifstream inputFile("TICKET.INP");
if (!inputFile.is_open()) {
std::cerr << "Khong the mo tep TICKET.INP" << std::endl;
return 1;
}
int n;
inputFile >> n;
std::vector<Person> people;
for (int i = 1; i <= n; ++i) {
Person person;
person.index = i;
inputFile >> person.time;
people.push_back(person);
}
// Đóng tệp TICKET.INP
inputFile.close();
// Sắp xếp danh sách người theo thời gian mua vé tăng dần
std::sort(people.begin(), people.end(), compareByTime);
// Tìm người mua vé cặp để tổng thời gian bán vé là ít nhất
int totalTime = 0;
int minTotalTime = INT_MAX;
int bestPairIndex = -1;
for (int i = 0; i < n - 1; ++i) {
totalTime += people[i].time;
if (totalTime + people[i + 1].time < minTotalTime) {
minTotalTime = totalTime + people[i + 1].time;
bestPairIndex = i;
}
}
// Ghi kết quả ra màn hình
std::cout << "Nguyen vien ban ve can ban ve cap cho nguoi thu: " << people[bestPairIndex + 1].index << std::endl;
return 0;
}
Công thức để tính:
1) Tổng vé đã bán cho từng phim.
Sau đó sao chép công thức sang ô E5:E7
2) Doanh thu cho từng phim.
- Thiết lập công thức cho ô F4
- Sao chép sang ô F5:F7
3) Tổng doanh thu phòng vé.
Công thức:
Kết quả:
Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln((a+b)/2:4:2);
readln;
end.
#include<bits/stdc++.h>
using namespace std;
int main() {
int T, n;
cin>>T;
for(int t=0;t<T;t++){
int n,k,a,i;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans=0;
int c=0;
int sum=0;
int c0=0;
int c1=0;
int c2=0;
for(int i=0;i<n;i++){
sum+=a[i];
}
for(int i=0;i<n;i++){
if(sum<k && i!=0){
sum+=a[i]-1;
}
}
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
int sum=0;
for(int l=i;l<j;l++){
sum+=a[l];
}
if(sum==k){
c0=i;
c1=j;
}
}
}
printf("Case %d : %d - %d (c0,c1)\n",t+1,c*n+c0,c*n+c1);
++c;
}
return 0;
}