Submission #1279145

#TimeUsernameProblemLanguageResultExecution timeMemory
1279145abyfuFancy Fence (CEOI20_fancyfence)C++20
0 / 100
1101 ms49884 KiB
//OwO
//#pragma GCC optimize("O3", "unroll-loops", "O2", "Ofast")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define namein "input.txt"
#define nameout "output.txt"
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define m_pi acos(-1)
using namespace std;
const ll inf = 1e18;    
const int linf = 1.5e9;

void file(){
    if (fopen(namein, "r")){
        freopen(namein, "r", stdin);
        freopen(nameout, "w", stdout);
    }   
}

const ll mod = 1e9 + 7;
const int N = 2e5 + 5, M = 5e5 + 5;
int n;
int h[N], w[N];
set<int> x;

ll sub3(){
    ll u = *x.begin();
    ll v = 0;
    for (int i = 1; i <= n; i++) v += w[i];
    cout << v*(v + 1)/2*u % mod;
}

void run(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> h[i] >> w[i];
        x.insert(h[i]);
    }
    if (x.size() == 1){
        cout << sub3();
        return;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    file();
    run();
}

Compilation message (stderr)

fancyfence.cpp: In function 'long long int sub3()':
fancyfence.cpp:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
fancyfence.cpp: In function 'void file()':
fancyfence.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(namein, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(nameout, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...