답안 #945880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945880 2024-03-14T08:22:25 Z hariaakas646 송금 (JOI19_remittance) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, l, r) for(int i=l; i<r; i++)
#define frange(i, l) forr(i, 0, l)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef long long lli;
typedef vector<vi> vvi;
typedef vector<lli> vll;
typedef vector<bool> vb;
typedef set<int> seti;
typedef multiset<int> mseti;
 
void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int main() {
    // usaco();
    int n;
    scd(n);
    vii vec(n);
    priority_queue<pair<int, int>> pq;
    frange(i, n) {
        scd(vec[i].f);
        scd(vec[i].s);
        if(vec[i].s < vec[i].f) pq.push(mp(vec[i].f - vec[i].s, i));
    }

    while(pq.size()) {
        auto p = pq.top();
        pq.pop();
        int i = p.s;
        if(p.f != vec[i].f - vec[i].s || p.f == 1) continue;
        if(p.f % 2) {
            vec[i].f = vec[i].s + 1;
            vec[(i+1)%n].f = vec[(i+1)%n].f + (p.f/2);
        }
        else {
            vec[i].f = vec[i].s;
            vec[(i+1)%n].f  = vec[(i+1)%n].f + (p.f/2);
        }
        int id = (i+1)%n;
        if(vec[id].s < vec[id].f) pq.push(mp(vec[id].f - vec[id].s, id));
    }
    bool done = true;
    frange(i, n) {
        if(vec[i].f != vec[i].s) done = false;
    }
    if(done) printf("Yes\n");
    else printf("No\n");

}

Compilation message

remittance.cpp: In function 'void usaco()':
remittance.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp: In function 'int main()':
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:34:5: note: in expansion of macro 'scd'
   34 |     scd(n);
      |     ^~~
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:38:9: note: in expansion of macro 'scd'
   38 |         scd(vec[i].f);
      |         ^~~
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:39:9: note: in expansion of macro 'scd'
   39 |         scd(vec[i].s);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -